[Issue 20508] New: std.math.pow(-infinity, y) does not return NaN for imaginary or complex results
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 15 19:45:12 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20508
Issue ID: 20508
Summary: std.math.pow(-infinity, y) does not return NaN for
imaginary or complex results
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: thomas.bockman at gmail.com
void main() {
import std.stdio, std.math;
writefln("%s", pow(-double.infinity, 0.5)); // wrongly prints "inf"
writefln("%s", sqrt(-double.infinity)); // correctly prints "-nan"
}
I realize that pow() is following the spec given in the documentation here, and
that at least some implementations of the C standard library apparently do the
same thing.
But, the behaviour of pow() is mathematically incorrect here, and sabotages the
ability of floating-point algorithms to detect and handle the generation of
imaginary and complex results properly.
Is there an actual good reason it works this way, or was this just copied from
some broken C implementation?
--
More information about the Digitalmars-d-bugs
mailing list