Article View: comp.arch
Article #21760Re: IEEE 754 "rem" query
From: Tim Olson
Date: Fri, 15 Dec 1989 14:40
Date: Fri, 15 Dec 1989 14:40
29 lines
1961 bytes
1961 bytes
In article <1291@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes:
| I have read the IEEE 754 and IEEE 854 standards as carefully as I can,
| and it is not clear to me what the sign of x REM y should be when x=0.
| x REM y is "defined ... by the mathematical relation r = x - y.n"
| in section 5.1. If we thought of this as involving an subtraction in
| the implementation, section 6.3's rule that "when the sum of two operands
| with opposite signs (or the difference of two operands with like signs)
| is exactly zero, the sign of that sum (or difference) shall be "+" in
| all rounding modes except round towards -oo, in which mode that sign
| shall be "-". However, x+x = x-(-x) retains the same sign as x even
| when x is zero." This would mean that the sign of -0.0 REM y might be
| "+" or "-" depending on the sign of "y.n". However, (a) the sign of y.n
| is not defined because this is a mathematical multiplication, not an IEEE
| one, and (b) if we took this reading the result of (-0.0 REM y) would
| depend on the rounding mode, and x REM y is "defined regardless of the
| rounding mode".
|
| I think the result of (-0.0 REM y) should be -0.0 for any non-zero y, and
| that's what I get when I try it, but is that the intent of the standard?
Yes. My copy of the Standard 754 (admittedly old) says:
"... r = x - y*n, where n is the integer nearest the exact value
x/y... If r=0, its sign shall be that of x."
-- Tim Olson
Advanced Micro Devices
(tim@amd.com)
Technical Details
Message-ID:
<28412@amdcad.AMD.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!ames!amdcad!nucleus!timReferences:
<1291@quintus.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!ames!amdcad!nucleus!tim From: tim@nucleus.amd.com (Tim Olson) Newsgroups: comp.arch Subject: Re: IEEE 754 "rem" query Message-ID: <28412@amdcad.AMD.COM> Date: 15 Dec 89 14:40:39 GMT References: <1291@quintus.UUCP> Sender: news@amdcad.AMD.COM Reply-To: tim@amd.com (Tim Olson) Organization: Advanced Micro Devices, Inc., Austin, Texas Lines: 29