checking for overflow in C

Blair P. Houghton bph at buengc.BU.EDU
Wed May 10 20:56:12 AEST 1989


In article <17981 at cisunx.UUCP> jcbst3 at unix.cis.pittsburgh.edu (James C. Benz) writes:
>In article <436 at cbnewsm.ATT.COM> mnc at cbnewsm.ATT.COM (michael.n.condict) writes:
>>In article <10218 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>>>In article <13367 at dartvax.Dartmouth.EDU> shallit at eleazar.dartmouth.edu (Jeffrey Shallit) writes:
>>>>... enlighten me about the officially approved way of checking
>>>>overflow when multiplying two integers.
[...much dancing deleted...]

I know it's overhead-city, but could someone try taking logarithms, adding
them, and checking them against the logarithm of the maximum-allowable
number?

				--Blair
				  "Yeah, but except for the last couple
				   of bits, it's idiot-proofed."



More information about the Comp.lang.c mailing list