From: Robert Dober Date: 2006-05-25T18:04:08+09:00 Subject: Re: greatest float smaller than 1.0? ------=_Part_187308_7679219.1148547844984 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 5/17/06, polypus wrote: > > > how do i get the greatest float smaller than 1.0? > > thanks > > -- > Posted via http://www.ruby-forum.com/. > > I agree with the answers that this question is dangerous and meaningless unless it is not. Assuming that you know what you need this is one way how the ruby interpreter can tell you what that number might be (from its point of view)= , although it should not exist ;) You have be warned about all kind of issues I will not repeat them. Cheers Robert ------------------------ 8< -------------------------------- #!/usr/bin/env ruby delta =3D Float::EPSILON while (y =3D 1.0 - delta) < 1.0 do delta /=3D 2.0 puts "%0.30f %0.30f" % [delta, y] end puts "%0.30f %0.30f" % [delta, y] On my machine I get robert@roma:~/ruby/tests$ ruby float.rb 0.000000000000000111022302462516 0.999999999999999777955395074969 0.000000000000000055511151231258 0.999999999999999888977697537484 0.000000000000000055511151231258 1.000000000000000000000000000000 you might get something else. --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_187308_7679219.1148547844984--