[bigint] Bug in BigUnsigned <<

Aidan Hobson Sayers <aidanhs at live.co.uk>
Wed Dec 28 20:25:40 PST 2011


Simply put, shifting a BigUnsigned value of 0 left seems to populate 
blocks with 0's.
This would be fine, but there's no zapLeadingZero()'s call at the end of 
BigUnsigned::bitShiftLeft(const BigUnsigned &a, int b) - there's a 
comment that seems to be to the effect of "there can only be one leading 
zero here", which (as noted above, by shifting zero) is not true.

The only reason I came across this was when attempting to convert this 
many-blocked 0 back into an integer, which to my surprise threw an 
exception of "Value is too big [...]".

Of course, I might have completely misdiagnosed this given my C++ 
skills, but since adding "zapLeadingZeros();" at the end if the 
bitShiftLeft function fixes this particular problem I'm having, I think 
it might be close.

Cheers
Aidan


More information about the bigint mailing list