This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/48236] uint64_t and int64_t behave differently when converting to float


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48236

--- Comment #3 from Jon Valdes <juanval at gmail dot com> 2011-03-22 14:35:10 UTC ---
>From my understanding, a positive number should be casted to exactly the same
floating value representation regardless if the variable is signed or unsigned.
In fact, checking the failing values, we see this:

uint64_t ui: 16777217 -> (float) ui:16777216.000000 ( ui - 1  )
uint64_t ui: 16777218 -> (float) ui:16777218.000000 ( correct )
uint64_t ui: 16777219 -> (float) ui:16777220.000000 ( ui + 1  )  

The casting of a uint64_t value to float wiggles around the correct value, but
an int64_t value stays correct.

int64_t i : 16777217 -> (float) i:16777217.000000   ( correct ) 
int64_t i : 16777218 -> (float) i:16777218.000000   ( correct ) 
int64_t i : 16777219 -> (float) i:16777219.000000   ( correct )


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]