[LLVMbugs] [Bug 216] [llvmgcc] floating-point unary minus is incorrect for +0.0
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Mon Feb 2 09:45:05 PST 2004
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=216
sabre at nondot.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Summary|floating-point unary minus |[llvmgcc] floating-point
|is incorrect |unary minus is incorrect for
| |+0.0
Target Milestone|--- |1.2
------- Additional Comments From sabre at nondot.org 2004-02-02 11:45 -------
I surreptitiously started a thread on the GCC list about this topic, and got the
following response from Geoff Keating:
"""I looked this up. '-0.0 - X' is the same as '-0.0 + (-X)'. When -X
!= 0.0, the result will be -X, so that's OK. Suppose X is +/- 0.0.
Then the following rules apply:
- If both operands have the same sign, the sign of the result is the
same as the sign of the operands. So if X is +0.0, you'll get -0.0,
the same as -X.
- If the sum of two operands with opposite sign is exactly zero, the
sign is positive in all rounding modes except round towards -Inf, in
which case the sign is negative. So, if X is -0.0, you'll get
+0.0, the same as -X, *unless* we're rounding towards -Inf.
Thus, the answer to your question is "no". The case that differs is
when X is -0.0 and the rounding mode is towards -Inf."""
Which I interpret to mean "yes", it's the same in all cases except when the
rounding mode is tweaked to be -Inf, which is not the default. As this is the
case, I've commited the following patch to the CFE:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040202/011060.html
Note that will still will eventually need "strict" vs "non-strict" floating
point operators, particularly to support languages like Fortran and Java well.
-Chris
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list