Bug in multiprecision arithmetic, libmp

Grace L. Hammonds graceh at linus.UUCP
Mon Jul 11 00:27:54 AEST 1983


Does anyone have fixes for bugs in the arbitrary precision integer
arithmetic package that came with our 4.1bsd system, /usr/src/lib/libmp?  I
recently found a problem in the division routine, but there may be others I
haven't come across yet.  I discovered the bug when I tried to divide a
10-digit number into twice that number less one.  The remainder should have
been the divisor less one, but it was much too low.  The trouble seems to
start at 1073741825 = 2^30+1 (I haven't been able to get it to fail at
numbers smaller than that), where I get the following results:

	(2 * (2^30+1) - 1) mod (2^30+1) =  2^30-2,  instead of 2^30

Using 2^30+3:
	(2 * (2^30+3) - 1) mod (2^30+3) =  2^30-(2^16), instead of 2^30+2

Actually, any information you have on the package would be appreciated,
because it came undocumented.



More information about the Comp.unix.wizards mailing list