From: "Peña, Botp" Date: 2007-01-20T13:59:37+09:00 Subject: Re: Float to Fixnum (was: Negative Float conversion to Fixnum) From: Drew Raines [mailto:aaraines@gmail.com] : #-------------------------------------- # BigDecimal seems to be unaffected, so I guess I'll use that as a # workaround: # # >> (39.30*100).to_i # => 3929 #-------------------------------------- mixing integers and float is like mixing water w gasoline. expect disasters in all directions. irb(main):018:0> 39.30*100 == 3930 => false irb(main):019:0> 39.30*100 == 3939 => false ruby supports integers and floating point numbers (wc in turn are supported by the hw architecture). imho, there's a big gap/hole for the representation of plain decimals (usurped by floating point in this case). #-------------------------------------- # >> (39.30*100).to_d.to_i # => 3930 #-------------------------------------- indeed. 99% of the my time, i find no use for floats (maybe i'm scared of surprises). i'd suggest a global $DECIMAL=1 to instruct ruby to bigdecimal mode so that >> 39.30*100 == 3930 => true >> (39.30*100).to_i # no need for to_d there, 39.30 is decimal, right? ;) => 3930 i really do not care if it would be slower. i chosed ruby anyway. kind regards -botp