From: Vincent Fourmond Date: 2007-03-03T02:54:39+09:00 Subject: Re: Floats that are NaN have strange behavior Jonas Kongslund wrote: > Hi > > I'm playing around with Ruby and noticed the following behavior on the > float 0.0/0.0 which is NaN: > > (0.0/0.0).zero? evaluates to true. I would expect false. > (0.0/0.0).nonzero? evaluates to nil. I would expect NaN. Sorry, which version of ruby is it ? I get the following for 1.8 (debian) and a fairly recent 1.9 from SVN: irb(main):001:0> a = 0.0/0.0 => NaN irb(main):002:0> a.zero? => false irb(main):003:0> a.nonzero? => NaN irb(main):004:0> (0.0/0.0).zero? => false irb(main):005:0> (0.0/0.0).nonzero? => NaN Cheers, Vince -- Vincent Fourmond, PhD student (not for long anymore) http://vincent.fourmond.neuf.fr/