Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
January 11, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 e10s <electrolysis.jp+d@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |electrolysis.jp+d@gmail.com --- Comment #1 from e10s <electrolysis.jp+d@gmail.com> --- https://github.com/D-Programming-Language/phobos/pull/2864 -- |
January 25, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 --- Comment #2 from github-bugzilla@puremagic.com --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f8bb3e4cd8f90af3d9004392f7668759d57005f2 Fix Issue 13963 - BigInt modulo ulong is rejected https://github.com/D-Programming-Language/phobos/commit/3fbb2c33dd7687d8d8538903878f5d60e4362e27 Merge pull request #2864 from e10s/patch-6 Fix Issue 13963 - BigInt modulo ulong is rejected -- |
January 25, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 github-bugzilla@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED -- |
January 25, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 mfx <markus@oberhumer.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |--- --- Comment #3 from mfx <markus@oberhumer.com> --- Thanks for the fix, but we still have some problem here: import std.bigint; void main() { import std.typetuple : TypeTuple; import std.stdio : writeln; // assert that "y = x % b" has same value as "x %= b" void checkMod(T)(T a, T b) { BigInt x = a; auto y = x % b; x %= b; //assert(x == y); if (x != y) writeln("BitInt modulo ERROR: ", typeid(T), " ", a, " ", b, " ", x, " ", y); } foreach(T; TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong)) { immutable T[] values = [T.min, T.min + 1, 0, T.max - 1, T.max]; foreach(a; values) foreach(b; values) if (b != 0) checkMod!T(a, b); } } -- |
January 25, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 --- Comment #4 from mfx <markus@oberhumer.com> --- This patch seems to fix the issue for me. The unittest will still have to get updated. --- dmd-phobos.git/std/bigint.d 2015-01-25 06:45:36.000000000 +0100 +++ bigint.d 2015-01-25 10:34:57.000000000 +0100 @@ -157,6 +157,8 @@ } // x%y always has the same sign as x. // This is not the same as mathematical mod. + if (data.isZero()) + sign = false; } else static if (op==">>" || op=="<<") { @@ -279,6 +281,14 @@ return r; } } + else static if (is(Unqual!T == uint)) + { + uint u = absUnsign(y); + long rem = BigUint.modInt(data, u); + // x%y always has the same sign as x. + // This is not the same as mathematical mod. + return sign ? -rem : rem; + } else { uint u = absUnsign(y); -- |
January 25, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 --- Comment #5 from e10s <electrolysis.jp+d@gmail.com> --- Thank you for your report! However, it's beyond the range of this issue. I hope you will report it as a different one ;) Furthermore, I think the "-0" problem and the uint problem should be treated as individuals. -- |
February 01, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 mfx <markus@oberhumer.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |FIXED --- Comment #6 from mfx <markus@oberhumer.com> --- Closing this issue. Fix it or leave it. But see "the perfect is the enemy of the good" in https://github.com/klamonte/cycle/blob/master/docs/no_more_d.md -- |
February 08, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 --- Comment #7 from e10s <electrolysis.jp+d@gmail.com> --- Issue 14124 - BigInt %= int can return "-0" -- |
February 18, 2015 [Issue 13963] BigInt modulo ulong is rejected | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13963 --- Comment #8 from github-bugzilla@puremagic.com --- Commits pushed to 2.067 at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f8bb3e4cd8f90af3d9004392f7668759d57005f2 Fix Issue 13963 - BigInt modulo ulong is rejected https://github.com/D-Programming-Language/phobos/commit/3fbb2c33dd7687d8d8538903878f5d60e4362e27 Merge pull request #2864 from e10s/patch-6 -- |
Copyright © 1999-2021 by the D Language Foundation