Comment #0 by killebrew.daniel — 2014-02-23T14:56:51Z
There seems to be a bug in BigInt where a value==0, but value>0==true.
import std.stdio;
import std.bigint;
void main() {
{
//works
BigInt evil = 107;
int counter;
while (evil != 0){
evil /= 10;
}
}
{
//fails
BigInt evil = 107;
int counter;
while (evil > 0){
evil /= 10;
++counter;
if(counter > 5) {
assert(evil == 0);
throw new Exception("evil==0, but we're still looping, so evil>0... this doesn't make sense");
}
}
}
}
The code will throw the exception. The evil==0 comparison works as expected. The evil>0 comparison gives a wrong answer.
Comment #1 by killebrew.daniel — 2014-02-23T16:17:27Z
Comment #2 by safety0ff.bugz — 2014-02-23T17:43:48Z
See bug report #11583 for the commit & PR that fixed this. The unit test should already be there to prevent regression.
*** This issue has been marked as a duplicate of issue 11583 ***
Comment #3 by github-bugzilla — 2014-03-14T01:45:53Z