At 17:08 24.06.03 +0900, Holden Glova wrote:

>I am curious what people use to represent decimals when with no rounding
>error? I have a need for this and have come up against a brick wall. I was
>hoping for something that was similar to BigDecimal in Java - does Ruby have
>anything like this?

I have had this problem for years until I started use Ruby. Fundamentally, 
there are at least 6 number fields: N < Z < D < Q < R < C (natural < 
integer < decimal < rational < real < complex). Computers cannot deal with 
real and complex numbers => round-off errors. However, Ruby lets you work 
with infinite precision Bignum and since decimal numbers are contained 
within the rational number field you can safely use rational numbers to 
store decimal information. I simply equipped the Rational class with a 
#to_s method which writes the number to a string and reads it back again to 
check that no information has been lost. The string representation of my 
Rational is therefore Fixnum, Bignum, Float or Rational depending on how 
many digits are needed.

Tore Haug-Warberg