[Issue 5174] New: -x ^^ 0 returns -1

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 5 13:15:14 PDT 2010


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

           Summary: -x ^^ 0 returns -1
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ibuclaw at ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw at ubuntu.com> 2010-11-05 13:14:14 PDT ---
Code:
import std.stdio;
import std.math;

void main(string[] args)
{
    writefln("test:   %s%6s", "pow()", "^^");

    writefln("-3^^0:  %s%10s", pow(-3, 0), -3^^0);
    writefln("-2^^0:  %s%10s", pow(-2, 0), -2^^0);
    writefln("-1^^0:  %s%10s", pow(-1, 0), -1^^0);
    writefln(" 0^^0:  %s%10s", pow( 0, 0),  0^^0);
    writefln(" 1^^0:  %s%10s", pow( 1, 0),  1^^0);
    writefln(" 2^^0:  %s%10s", pow( 2, 0),  2^^0);
    writefln(" 3^^0:  %s%10s", pow( 3, 0),  3^^0);
}


Outputs:
test:   pow()    ^^
-3^^0:  1        -1
-2^^0:  1        -1
-1^^0:  1        -1
 0^^0:  1         1
 1^^0:  1         1
 2^^0:  1         1
 3^^0:  1         1



Note that zero, and positive to the power of 0 match the return value of pow().
But negative numbers to the power of 0 don't.

Marking as major because this could cause confusion.

Regards

-- 
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