Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!csd4.milw.wisc.edu!uxc!garcon!uicsrd.csrd.uiuc.edu!mcdaniel From: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Newsgroups: comp.lang.c Subject: Re: How to multiply two ints and check overflow Keywords: overflow Message-ID: <1056@garcon.cso.uiuc.edu> Date: 19 May 89 00:19:27 GMT References: <434@skye.ed.ac.uk> <1034@garcon.cso.uiuc.edu> Sender: news@garcon.cso.uiuc.edu Reply-To: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Organization: Center for Supercomputing R&D (Cedar), U. of Ill. Lines: 22 The INT_MIN and INT_MAX #defines are there for non-pANS C sites; they're inherently unportable. If INT_MIN is #defined as (-2147483648) it may not work (it may get the wrong type, according to Chris Torek). INT_MIN may have to be #defined as (-2147483647 - 1) or (0x80000000) or even just (-2147483647) if your compiler won't let you input -(2**32) and you're willing to sacrifice the smallest int. (INT_MIN and INT_MAX don't have to be exact, or even close, for my safemul code to work.) -- "6:20 O Timothy, keep that which is committed to thy trust, avoiding profane and vain babblings, and oppositions of science falsely so called: 6:21 Which some professing have erred concerning the faith." Tim, the Bizarre and Oddly-Dressed Enchanter | mcdaniel@uicsrd.csrd.uiuc.edu {uunet,convex,pur-ee}!uiucuxc!uicsrd!mcdaniel mcdaniel%uicsrd@{uxc.cso.uiuc.edu,uiuc.csnet}