From: Husein Choroomi Date: 2007-04-01T01:05:11+09:00 Subject: Re: NaN return > so 0.693524996891893 seems to be greater than 0.197314075476553 ???? becasue 0.6 is greater than 0.1 ! On 3/31/07, Josselin wrote: > On 2007-03-31 16:43:58 +0200, "Luis Parravicini" said: > > > On 3/31/07, Josselin wrote: > >> something like.. > >> cd = proposal.distance_to(current_city) != NaN ? > >> proposal.distance_to(current_city) : 0.0 > > > > Float has a 'nan?' method > > (http://www.ruby-doc.org/core/classes/Float.html#M000244). > > thanks, I got it to test and replace cd : cd = 0.0 if cd.nan? > > Float comparison is quite strange : > cd = 0.0 > => 0.0 > > irb(main):010:0> d = 0.197314075476553 > => 0.197314075476553 > > irb(main):011:0> (cd <=> d) > 0 > => false > > BUT ..... > > irb(main):006:0> cd = 0.693524996891893 > => 0.693524996891893 > > irb(main):007:0> d = 0.197314075476553 > => 0.197314075476553 > > irb(main):008:0> (cd <=> d) > 0 > => true > > so 0.693524996891893 seems to be greater than 0.197314075476553 ???? > > > -- Husein Choroomi, CEO, CTO Yucca Intelligence Development http://www.YuccaHQ.com We make the web a better place!