home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / programm / 2423 < prev    next >
Encoding:
Text File  |  1992-08-21  |  1.5 KB  |  39 lines

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