From: Marnen Laibow-Koser Date: 2009-12-01T23:15:50+09:00 Subject: Re: Float Arithmetic: Return A Fixnum When Float == Fixnum Marnen Laibow-Koser wrote: > MaggotChild wrote: >>>> j = 5/2.0 >> => 2.5 >> >> I'm fine with this >> >>>> j = 4/2.0 >> => 2.0 >> >> Useless precision -for me. I want 2! > > The notation is misleading. It's not a question of precision, but of > type. You can think of 2.0 as 2:Float, not 2 to 2 significant figures. > >> >>>> j == j.to_i ? j.to_i : j >> => 2 >> >> Is there a "better" way? > > Why even bother? > > Best, > --  > Marnen Laibow-Koser > http://www.marnen.org > marnen@marnen.org It occurs to me that you may also want to play with Rational. Best, --  Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.