This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/48236] uint64_t and int64_t behave differently when converting to float
- From: "juanval at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Mar 2011 14:35:15 +0000
- Subject: [Bug c/48236] uint64_t and int64_t behave differently when converting to float
- Auto-submitted: auto-generated
- References: <bug-48236-4@http.gcc.gnu.org/bugzilla/>
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 )