Re: [GD-General] ieee754 -0.0f?
Brought to you by:
vexxed72
|
From: Andras B. <and...@gm...> - 2006-02-01 17:51:09
|
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 <pe...@to...> 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
|