From: Roger Pack Date: 2010-05-12T00:09:24+09:00 Subject: Re: ruby 1.9+ , floats, and decimal > 1). Just because BigDecimal has what seems like better behavior in > some cases compared to a binary float, it has just as many problems in > other cases. > > (BigDecimal("1") / BigDecimal("3")).to_s > => "0.333333333333333333333333333333333333E0" > > Both binary and decimal floats have an infinite number of real > numbers which they can't express exactly. Good point. Maybe a good default would be Rational then? >> Rational(1,3) => (1/3) > And extended example which might make the point a bit better: > ((BigDecimal("1") / BigDecimal("3"))*BigDecimal("3")).to_s > => "0.999999999999999999999999999999999999E0" That one seemed to work ok. Was your point that it is limited to 36 decimals by default? Thanks! -rp -- Posted via http://www.ruby-forum.com/.