From: "W. Kent Starr" Date: 2002-12-27T16:55:22+09:00 Subject: Re: 1210 / 100 = 12? what? On Fri, 2002-12-27 at 01:37, Tom Sawyer wrote: > On Thursday 26 December 2002 11:27 pm, Tom Sawyer wrote: > > no i didn't realize that. i thought ruby would automatically change it to a > > float if need be, i.e. with divison, just as it changes to Bignum if need > > be. > > > > honestly i don't like it. now i have to go around adding .0's all over the > > place to make sure the math comes out right. and in some places i have to > > do things like multiple by 1.0 b/c certain values come from cgi script > > variables i have no control over. > > note to self: > .to_f not * 1.0 > > Also, if 1210 / 10 == 12.1 is your DESIRED and EXPECTED behavior for the project you are working on, use the beauty of Ruby and simply alter class Fixnum and be done with it. class Fixnum def /(n) to_f / n end end Beats adding 0's all over the place :-) (Note1: tested in Ruby 1.73, but should be backwards compatible.) (Note2: for projects under your direct control only; such "fixes" will break POLS for experienced Rubyists!!!) Regards, Kent Starr