Re: [GD-General] ieee754 -0.0f?
Brought to you by:
vexxed72
From: Jim T. <jim...@gm...> - 2006-02-01 18:19:55
|
Brian, Hmmm, are you sure about those values? It thought the following was true: Zeroes are special in IEEE574 since there is an implicit leading 1 in the mantissa for 754 (which makes it impossible to get zero regardless of which exponent we choose). So there are special values for zeroes in 754, similarily to how Inf and NaN are specially represented. Conviniently , positive zero is all zeroes and negative zero just have the high bit set. +0.0f =3D 0x00000000 -0.0f =3D 0x80000000 I don't have VC6 here, but for VC7 on a regular P4 box the following produces the expected results: #include <cstdio> void main() { float a =3D 0.0f; float b =3D 0.0f/-1.0f; printf( "%f =3D 0x%8.8x\n", a, *(int*)&a ); printf( "%f =3D 0x%8.8x\n", b, *(int*)&b ); } /j On 2/1/06, Brian Hook <ho...@bo...> wrote: > > On Wed, 01 Feb 2006 09:50:00 -0700, Andras Balogh wrote: > > I know that -0.0f =3D=3D +0.0f is true, but the floating point > > representation of the two numbers should be different, no? > > They are different, on an IEEE compliant system. IEEE-754 has the > high bit reserved for sign, such that on a 32-bit system you would > have: > > -0.0 =3D 0xbf800000 > +0.0 =3D 0x3f800000 > > > Shouldn't the negative zero have the sign bit set? Well, on my > > machine -0.0 and 0.0 are bitwise equal!! What's going on here? > > You didn't mention the language or how you're generating those values. > Using VC6 on a Pentium-M by setting global floats I get the correct > and expected values. > > Brian > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmdlnk&kid=103432&bid#0486&dat=121642 > _______________________________________________ > Gamedevlists-general mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU7 > |