Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!oddjob!hao!noao!arizona!mike From: mike@arizona.edu (Mike Coffin) Newsgroups: comp.bugs.4bsd,sci.math.symbolic Subject: Re: Bug in bc square root routine Message-ID: <1661@megaron.arizona.edu> Date: Mon, 27-Apr-87 15:23:15 EDT Article-I.D.: megaron.1661 Posted: Mon Apr 27 15:23:15 1987 Date-Received: Wed, 29-Apr-87 04:41:16 EDT References: <4534@sdcrdcf.UUCP> Organization: U of Arizona CS Dept, Tucson Lines: 32 Summary: The division routine is bad, too. Xref: mnetor comp.bugs.4bsd:329 sci.math.symbolic:70 In article <4534@sdcrdcf.UUCP>, pmontgom@sdcrdcf.UUCP (Peter Montgomery) gives an example of a bc program that produces an incorrect square root. I do not know if this is related, but there is also bug in the division routine of bc, at least on VAX running Berkley 4.2 and 4.3. I had several examples of this once; this is the only one I can find at the moment: ------------------------------------------------------------------------- % bc obase=16 ibase=16 a = 519E2FEA51A537AB0132DC6F3678E8539F1BEF64109473F752 b = A2F01268A40089 a 519E2FEA51A537AB0132DC6F3678E8539F1BEF64109473F752 b A2F01268A40089 c = a/b c 803BF0FC7753CC1552D0A09B286CAAEBE771 a-(b*c) F530645557A101E4C95E9095BD9 obase=A c 11170769584511689511742018590-12440481240754033 --------------------------------------------------------------------------- The variable c in the above transcript is obviously bogus; a mod b cannot be larger than b. And, when printed in base 10, it contains a minus-sign. BTW, the correct answer for c is 803BF0FC7753CC1552D0A0CE7125CE93A4C4 (base 16). mike coffin (mike@arizona.edu)