Re: SPAM Re: ieee754 -0.0f?

Peter <[email protected]> Wed, 01 Feb 2006 10:47:44 -0800
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
then it's your compiler. When it translates the string/token "-0.0f" 
apparently it's smart enough to generate a 'real' zero. I don't know of 
any requirement that a compiler supports explicit generation of -0 in 
any form; only that its underlying math behaves correctly.
  So if you try this:
union { unsigned int asUInt; float asFloat; } val;  val.asUInt = 
0x80000000; printf("%f",val.asFloat);
  you -may- see -0.0f depending on whether your printf implementation 
cares to show the difference!  Personally I've frequently been bitten by 
quirks in the way a debugger's windows accept input or display output - 
you need to look at a hex or binary display of memory and registers, and 
use an assembly (rather than source-level) debug, to be sure of what's 
really happening.

Peter

Andras Balogh wrote:

> I run this code:
>
> float f = -0.0f;
> void* p = *(reinterpret_cast<void**>(&f));
> ::printf("%f = %p\n", f, p);
>
> And it prints all zeroes. For any other number I see the correct  
> hexadecimal representation of the float number.
>
>
> Thanks,
>
> Andras
>
>
>
> On Wed, 01 Feb 2006 10:32:28 -0700, Peter <[email protected]> wrote:
>
>> what is the context here?  If you're interpreting 0x80000000 (32 bit  
>> int) as a 32-bit IEEE float it's -0.0f   and 0x00000000 is 0.0f.
>>   Where are you seeing the -0.0f? In a debugger? I think you must be  
>> seeing some idiosyncrasy of your development environment or toolchain.
>>
>> Andras Balogh wrote:
>>
>>> I know that -0.0f == +0.0f is true, but the floating point  
>>> representation  of the two numbers should be different, no? 
>>> 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?
>>>
>>> thx,
>>>
>>>
>>> Andras
>>
>
>
> -------------------------------------------------------
> 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?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Gamedevlists-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=557
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email 
> ______________________________________________________________________
>




-------------------------------------------------------
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?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557