[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Newb math question

Nuralanur

6/9/2005 11:29:00 AM

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/rationa...
(http://www.ruby-doc.org/stdlib/libdoc/rational/rdoc/files/ration...)


Best regards,

Axel