home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / compiler / 1834 < prev    next >
Encoding:
Internet Message Format  |  1992-11-10  |  1.8 KB

  1. Path: sparky!uunet!ogicse!das-news.harvard.edu!spdcc!iecc!compilers-sender
  2. From: joe@babel.ho.att.com (Joseph M Orost)
  3. Newsgroups: comp.compilers
  4. Subject: Re: Constant divisions, remainders
  5. Keywords: arithmetic
  6. Message-ID: <92-11-025@comp.compilers>
  7. Date: 5 Nov 92 13:16:46 GMT
  8. Article-I.D.: comp.92-11-025
  9. References: <92-10-075@comp.compilers> <92-11-006@comp.compilers>
  10. Sender: compilers-sender@iecc.cambridge.ma.us
  11. Reply-To: joe@babel.ho.att.com (Joseph M Orost)
  12. Organization: Echo Logic
  13. Lines: 33
  14. Approved: compilers@iecc.cambridge.ma.us
  15.  
  16. kelsey@flora.ccs.northeastern.edu writes:
  17. [Right shift isn't the same as division when the dividend is negative.]
  18.  
  19. torbenm@diku.dk (Torben AEgidius Mogensen) writes:
  20. >This depends on how you define div and mod for negative integers. The most
  21. >usually found "definition" is that div rounds towards 0, and that mod is
  22. >signed. But most mathematicians prefer to make div always round down and
  23. >that mod is nonnegative. ...
  24. >
  25. >I think the round-to-zero rule for div and signed mod are relics from ones
  26. >complement computers, and should be laid to rest.
  27.  
  28. The problem with this thinking is that you will get inconsistent results
  29. if you divide by a constant power-of-2 versus dividing by a variable with
  30. the same value.  And you will get LOTS of bug reports from the compiler
  31. users!
  32.  
  33. In order to have the round-to-zero rule "laid to rest," first you have to
  34. convince all the hardware designers out there that their DIV instruction
  35. is broken: GOOD LUCK!
  36.  
  37.                                 regards,
  38.                                 joe
  39.  
  40. --
  41. Full Name:    Joseph M. Orost
  42. EMail:        joe@babel.ho.att.com
  43. Organization: Echo Logic
  44. SurfaceMail:  943 Holmdel Rd.; Cruz Plaza; Holmdel, NJ 07733
  45. Phone:        +1 (908) 946-1115
  46. -- 
  47. Send compilers articles to compilers@iecc.cambridge.ma.us or
  48. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  49.