[Issue 7548] New: Less specific lowering of power operator was chosen, causing 10.0L^^2 == 99.999999999999999993L

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 19 13:59:19 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7548

           Summary: Less specific lowering of power operator was chosen,
                    causing 10.0L^^2 == 99.999999999999999993L
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: kennytm at gmail.com


--- Comment #0 from kennytm at gmail.com 2012-02-19 13:59:17 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list