www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: kennytm gmail.com



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: -------
Feb 19 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7548


safety0ff.bugz gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz gmail.com



Patch in issue 11159 fixes this, r^^e was using CTFE.

One issue should be marked duplicate of the other.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7548


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |DUPLICATE



22:57:15 PDT ---
*** This issue has been marked as a duplicate of issue 11159 ***

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