This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/47146] Floating point to integer conversions
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 1 Jan 2011 18:21:03 +0000
- Subject: [Bug c/47146] Floating point to integer conversions
- Auto-submitted: auto-generated
- References: <bug-47146-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47146
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-01-01 18:21:01 UTC ---
(In reply to comment #0)
> Casting and rounding seems to be a problem.
Please be more specific.
Do you understand how floating point works?
Do you know that "0.39 * 100" has type double, not float, so has more precision
(and a different value) than "(float)0.39 * 100" ?
If you use doubles, or consistently use floats (not a mix of floats and
doubles) then you get consistent results