[Issue 8011] New: BigInt ++ and -- do wrong thing on negative numbers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 1 11:32:45 PDT 2012
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: nobody at puremagic.com
ReportedBy: c.m.brandenburg at gmail.com
--- Comment #0 from c.m.brandenburg at 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: -------
More information about the Digitalmars-d-bugs
mailing list