Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site linus.UUCP
Path: utzoo!linus!graceh
From: graceh@linus.UUCP (Grace L. Hammonds)
Newsgroups: net.bugs.4bsd,net.unix-wizards
Subject: Bug in multiprecision arithmetic, libmp
Message-ID: <26948@linus.UUCP>
Date: Sun, 10-Jul-83 10:27:54 EDT
Article-I.D.: linus.26948
Posted: Sun Jul 10 10:27:54 1983
Date-Received: Sun, 10-Jul-83 23:52:13 EDT
Organization: MITRE Corp., Bedford MA
Lines: 17


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.