Bug 4470 – Problems with std.bigint mod and divide
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-07-16T04:35:00Z
Last change time
2010-09-20T08:50:10Z
Assigned to
nobody
Creator
yebblies
Comments
Comment #0 by yebblies — 2010-07-16T04:35:08Z
With the version of std.bigint packaged with dmd2.047 (on winxp / x86)
1. You get 'object.Error: Win32 Exception'
when attempting any BigInt % BigInt(1) or BigInt % 1.
Test case:
import std.bigint;
void main()
{
auto r1 = BigInt(6) % 1;
auto r2 = BigInt(6) % BigInt(1);
}
2. BigInt % BigInt(0) seems to go into an infinite loop
import std.bigint;
void main()
{
auto r = BigInt(6) % BigInt(0);
}
Comment #1 by yebblies — 2010-07-16T04:49:08Z
The following tests should succeed when this issue has been fixed:
unittest
{
try
{
scope(success) assert(0);
auto r1 = BigInt(6) % BigInt(0);
} catch {}
try
{
scope(success) assert(0);
auto r1 = BigInt(6) % 0;
} catch {}
assert(BigInt(6) % BigInt(1) == 1);
assert(BigInt(6) % 1 == 1);
assert(BigInt(-6) % BigInt(-1) == -1);
assert(BigInt(-6) % -1 == -1);
}