On 2007-03-31 16:43:58 +0200, "Luis Parravicini" <lparravi / gmail.com> said:

> On 3/31/07, Josselin <josselin / wanadoo.fr> 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 ????