From: Jeff Schwab Date: 2009-04-29T05:25:06+09:00 Subject: Re: Detecting -0.0 Joel VanderWerf wrote: > Thomas B. wrote: >> Hello. >> >> I have a simple question - how to detect if a variable contains a Float >> of value -0.0? Is there any special method for this, or any comparison >> that distinguishes negative zero from a the regular zero? >> >> Thanks in advance. >> TPR. > > irb(main):001:0> x = -0.0 > => -0.0 > irb(main):002:0> x == 0.0 > => true > irb(main):003:0> x.eql?(0.0) > => true > irb(main):004:0> x.equal?(0.0) > => false What does that accomplish? irb(main):001:0> (-0.0).equal? -0.0 => false