[Issue 14786] The built-in exponentiation operator ^^ sometimes returns a value with the wrong sign.
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 8 01:04:03 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14786
--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject.org> ---
This seems to be the correct extract from std.math to look at:
---
5675│ // Result is real only if y is an integer
5676│ // Check for a non-zero fractional part
5677├> if (y > -1.0 / real.epsilon && y < 1.0 / real.epsilon)
5678│ {
5679│ long w = cast(long)y;
5680│ if (w != y)
5681│ return sqrt(x); // Complex result -- create a NaN
5682│ if (w & 1) sign = -1.0;
5683│ }
5684│ x = -x;
---
If 'e = long.max', it is representable, and the (w & 1) check sets sign to
'-1.0'
As instead 'e = long.max + 2', it is not representable, and so the signed-ness
is not adjusted.
Checked result against libm routines, and yes it looks like a bug on our side.
--
More information about the Digitalmars-d-bugs
mailing list