From: SF/projects/mingw n. l. <min...@li...> - 2012-10-22 17:45:57
|
Bugs item #2965184, was opened at 2010-03-07 14:32 Message generated for change (Comment added) made by earnie You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=2965184&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: gcc >Group: Aged issue >Status: Closed >Resolution: Out of Date Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Nobody/Anonymous (nobody) Summary: Unsigned 64bit Attribution from negative floating number Initial Comment: Accidentally I came across the strage behaviour when attributing a negative floating point number to a unsigned 64bit integer. For example, when attributing the value -1.0 to a 64bit integer instead of having the expected value (0xFFFF FFFF FFFF FFFF) the integer is attributed with the equivalent value if I used a 32bit value (0xFFFF FFFF). The attached file for test purposes is shown below: #include <stdio.h> int main ( ) { unsigned long long i; unsigned char* p; float f; int i2; p = ( unsigned char* ) &i; f = -1.0; i2 = -1; i = ( unsigned long long ) f; printf ( "From floating point: " ); for ( int k = 0; k < sizeof ( i ); ++ k ) { printf ( "%02X ", ( unsigned int ) p [k] ); } printf ( "\r\n" ); i = ( unsigned long long ) i2; printf ( "From signed integer: " ); for ( int k = 0; k < sizeof ( i ); ++ k ) { printf ( "%02X ", ( unsigned int ) p [k] ); } printf ( "\r\n" ); } The output of this test is: From floating point: FF FF FF FF 00 00 00 00 From signed integer: FF FF FF FF FF FF FF FF Thank you, I hope it helps Denis ---------------------------------------------------------------------- >Comment By: Earnie Boyd (earnie) Date: 2012-10-22 10:45 Message: Works for me with GCC 4.7.0. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=2965184&group_id=2435 |