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