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

           Summary: BigInt ++ and -- do wrong thing on negative numbers
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: c.m.brandenb...@gmail.com


--- Comment #0 from c.m.brandenb...@gmail.com 2012-05-01 11:33:55 PDT ---
The ++ and -- operators for BigInt do the wrong thing when operating on a
negative number. Specifically, ++ decrements and -- increments—opposite of what
it should be.

As an example, take the following program.

import std.bigint;
import std.stdio;

void main() {
    BigInt x;
    x = 1;
    writeln(++x);
    writeln(++x);
    x = -3;
    writeln(++x);
    writeln(++x);
    x = 1;
    writeln(--x);
    writeln(--x);
    writeln(--x);
    writeln(--x);
}

It outputs the following:

2
3
-4
-5
0
-1
0
-1

It _should_ output the following:

2
3
-2
-1
0
-1
-2
-3

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

Reply via email to