Bug 7548 – Less specific lowering of power operator was chosen, causing 10.0L^^2 == 99.999999999999999993L
Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-19T13:59:00Z
Last change time
2013-10-03T22:57:15Z
Assigned to
nobody
Creator
kennytm
Comments
Comment #0 by kennytm — 2012-02-19T13:59:17Z
Test case:
-----------------------------------
import std.math;
void main()
{
int e = 2;
real r = 10.0L;
assert(pow(r, e) == 100.0L); // passes
assert(r^^e == 100.0L); // fails on 64-bit.
}
-----------------------------------
The problem was 'r^^e' is using the version of 'std.math.pow' with a real exponent, although the version with integral exponent should be chosen, which allows a better precision.
The front end should avoid casting 'e2' in a PowExp to 'real' too early.
Comment #1 by safety0ff.bugz — 2013-10-02T22:17:52Z
Patch in issue 11159 fixes this, r^^e was using CTFE.
One issue should be marked duplicate of the other.
Comment #2 by bugzilla — 2013-10-03T22:57:15Z
*** This issue has been marked as a duplicate of issue 11159 ***