# Newb math question

**URL:** https://rubytalk.org/t/newb-math-question/18868
**Category:** ruby-talk
**Created:** [9 June 2005 11:29 UTC](https://rubytalk.org/t/newb-math-question/18868 "2005-06-09T11:29:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Nuralanur](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@Nuralanur](https://rubytalk.org/u/Nuralanur)
#### Post date: [9 June 2005 11:29 UTC](https://rubytalk.org/t/newb-math-question/18868/1 "2005-06-09T11:29:29Z")

</div>

Dear Brian,

you can avoid floating point problems altogether if you use fractions  
in your calculations.  
To do this, you can use the programme "rational.rb" which is  
part of ruby1.8.2 like this:

require "rational.rb"  
my\_result=9-Rational(89,10)

gives my\_result=Rational(1,10) (i.e. 1/10).

There is documentation on the methods available on

\_http://www.ruby-doc.org/stdlib/libdoc/rational/rdoc/files/rational\_rb.html\_  
([http://www.ruby-doc.org/stdlib/libdoc/rational/rdoc/files/rational\_rb.html](http://www.ruby-doc.org/stdlib/libdoc/rational/rdoc/files/rational_rb.html))

Best regards,

Axel
