checking for overflow in C

Karl Heuer karl at haddock.ima.isc.com
Tue May 9 08:30:53 AEST 1989


In article <10218 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In <13367 at dartvax.Dartmouth.EDU> shallit at eleazar (Jeffrey Shallit) writes:
>>... enlighten me about the officially approved way of checking overflow when
>>multiplying two integers.
>
>How did you get your algorithm into the state where an overflow is
>even possible?

Let's take a concrete example.  How do you think one should code the
implementation of the ANSI C function strtol(), which is required to detect
integer overflow and return ERANGE in this case?

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list