[Issue 17324] Floating point 1/(1/x) > 0 if x > 0 not generally true

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 9 03:21:04 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17324

--- Comment #1 from Don <clugdbug at yahoo.com.au> ---
Right, it's a bit sloppy, I'm treating +0.0 as "> 0".
The wording should actually be something like:

identities such as: x and 1/(1/x) always have the same sign bit.

(The point is that you can take the reciprocal without destroying the sign
bit).


>  assert(1/y > 0); // fails

That's because y is +infinity, so the result is +0.0.


>    assert(1/(1/x) > 0); // passes due to wrong optimuzation

That's not a problem, the compiler was able to avoid creating a spurious NaN.
It's allowed to use arbitrary intermediate precision.

--


More information about the Digitalmars-d-bugs mailing list