Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ico!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: checking for overflow in C Message-ID: <13003@haddock.ima.isc.com> Date: 8 May 89 22:30:53 GMT References: <13367@dartvax.Dartmouth.EDU> <10218@smoke.BRL.MIL> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 13 In article <10218@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In <13367@dartvax.Dartmouth.EDU> shallit@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@haddock.isc.com), The Walking Lint