home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!linus!progress!erf
- From: erf@progress.COM (Eric Feigenson)
- Subject: Detecting Integer Overflow/Underflow
- Message-ID: <1992Aug21.182206.15853@progress.com>
- Sender: usenet@progress.com (Mr. Usenet)
- Nntp-Posting-Host: ithaca
- Reply-To: erf@progress.com
- Organization: Progress Software Corp.
- Date: Fri, 21 Aug 1992 18:22:06 GMT
- Lines: 26
-
- I'm sure this is a solved problem, I just haven't been able to solve
- it :-)
-
- Given: Two numbers (integers) of the same bit-width (e.g., they're
- both stored as 16-bit integers), and writing in "C" (with no access to
- the assembly language of the machine; it must be portable!) is it
- possible to write code to detect whether the result of adding,
- substracting or multiplying the two numbers will result in overflow or
- underflow? The detection can be done either before or after the
- operation. It should, of course, be as efficient as possible, but any
- solutions are welcome.
-
- Thanks in advance for any and all suggestions!
-
- -EricF
-
- --
- Eric R. Feigenson UUCP: {mit-eddie,linus}!progress!erf
- Progress Software Corp. Internet: erf@progress.com
- 14 Oak Park DISCLAIMER: I don't speak for my employer,
- Bedford, MA 01730 and vice versa.
- --
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Kyle Tucker - Email Administrator | Progress Software Corporation
- tucker@bedford.progress.com | 14 Oak Park
-