From: "NAKAMURA, Hiroshi" Date: 2003-12-25T10:47:41+09:00 Subject: Re: Ruby 1.8.1 preview4 Hi, Dennis, > From: "Dennis Ranke" > Newsgroups: comp.lang.ruby > Sent: Wednesday, December 24, 2003 10:01 PM > > I can use "-1.0 / (1.0 / 0.0)" instead of "-0.0" for soap4r test. > > How does this dump? > > > > $ ruby -e 'p(-1.0 / (1.0 / 0.0))' > > -0.0 Thanks. Tests in 1.8.1 use this workaround. > Now, since the double is indeed converted to a single-precision float, this > is a known limitation of the Playstation 2 hardware which doesn't support > denormalized floats. The smallest (positive, non-zero) normalized float is > 2**-126, and all results smaller than that just (silently) underflow to > zero. Hmm. > The smallest positive non-zero single-precision float is exactly 2**-149, > so you could change your code to: > f = (d.abs < 2**-149) ? 0.0 : d Sure. It's intuitive. Regards, // NaHi