From: "Peña, Botp" Date: 2002-12-11T09:56:34+09:00 Subject: Re: warnings -w Hi sir Guy (aka ts [mailto:decoux@moulon.inra.fr]): You expounded last Tuesday, December 10, 2002 8:12 PM: > > Float#to_i is the same than Float#truncate > > pigeon% ruby -e 'p ((2.4/0.2).truncate)' > 11 > pigeon% > > pigeon% ruby -e 'p ((2.4/0.2).floor)' > 11 > pigeon% > > pigeon% ruby -e 'p ((2.4/0.2).ceil)' > 12 > pigeon% > > pigeon% ruby -e 'p ((2.4/0.2).round)' > 12 > pigeon% but irb(main):002:0> p "test #{2.4/0.2}" "test 12" nil irb(main):003:0> p 2.4/0.2 12 nil irb(main):004:0> 2.4/0.2 12 C:\family\ruby>type a1.rb def t 2.4/0.2 end x = t p x p x.truncate C:\family\ruby>ruby a1.rb 12 11 Isn't it that #to_i and #truncate exhibit odd and therefore dangerous behaviour? As a nuby, how do I avoid such "errors"? > Guy Decoux kind regards, -botp