From: Elias Athanasopoulos Date: 2004-05-06T16:17:17+09:00 Subject: Re: 0.0 sign On Thu, May 06, 2004 at 04:28:36AM +0900, Mark Hubbart wrote: > > On May 5, 2004, at 10:33 AM, Elias Athanasopoulos wrote: > > >Hello! > > > >I don't know if this is intentional, but is there a reason > >that 0.0 holds the sign? > > IEEE 754 (floating point arithmetic standard) specifies negative zero > for floats. For more explanation, see > http://www.obtuse.com/resources/negative_zero.html > > if a mathematical result too small for your hardware to compute is > returned, you can determine whether it was on the negative side, or the > positive side. > > def really_complex_function(num) > num/1_000_000_000_000_000_000.0 > end > ==>nil > really_complex_function( 0.000_000_000_000_000_000_1 ) > ==>0.0 > really_complex_function( -0.000_000_000_000_000_000_1 ) > ==>-0.0 Yes, but how can you distinguish them *inside* your code? Since 0.0 == -0.0, 0.0 === -0.0 and even 0.0.eql?(-0.0) is true. Regards, -- University of Athens I bet the human brain Physics Department is a kludge --Marvin Minsky