Re: Rounding with Div and Mod operators

anton@mips.complang.tuwien.ac.at (Anton Ertl)
20 May 1999 01:51:35 -0400

          From comp.compilers

Related articles
[6 earlier articles]
Re: Rounding with Div and Mod operators Scott.Daniels@Acm.Org (Scott.David.Daniels) (1999-05-16)
Re: Rounding with Div and Mod operators cdg@nullstone.com (Christopher Glaeser) (1999-05-16)
Re: Rounding with Div and Mod operators johan.persson@mbox319.swipnet.se (Johan Persson) (1999-05-16)
Re: Rounding with Div and Mod operators genew@shuswap.net (1999-05-20)
Re: Rounding with Div and Mod operators sofkam@rpi.edu (1999-05-20)
Re: Rounding with Div and Mod operators drh@microsoft.com (Dave Hanson) (1999-05-20)
Re: Rounding with Div and Mod operators anton@mips.complang.tuwien.ac.at (1999-05-20)
Re: Rounding with Div and Mod operators peter.r.wilson@boeing.com (Peter Wilson) (1999-05-20)
Re: Rounding with Div and Mod operators mfinney@lynchburg.net (1999-05-21)
Re: Rounding with Div and Mod operators jmoore@softmoore.com (John I. Moore, Jr.) (1999-05-22)
Re: Rounding with Div and Mod operators lassehp@imv.au.dk (1999-05-22)
Re: Rounding with Div and Mod operators r_barton1@hotmail.com (Barton) (1999-05-22)
Re: Rounding with Div and Mod operators r_barton1@hotmail.com (Barton) (1999-05-27)
[1 later articles]
| List of all articles for this month |

From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: 20 May 1999 01:51:35 -0400
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 99-05-039 99-05-056
Keywords: arithmetic, design

  "Scott.David.Daniels" <Scott.Daniels@Acm.Org> writes:
> One thing I'd mention is that each CPU manufacturer builds one of the
> definitions in hardware.


No. E.g., the Alpha architecture has no integer division instruction.
The 88k architecture had signed and unsigned integer division
instructions, but apparently the signed division is slow or broken on
the 88100, so signed division was synthesized out of unsigned division
in software.


> Here's an interesting question assuming a two's complement machine:
> Let MinInf = <sign bit on, all others off = most negative int = -1Q0>
> (points to those other old fogeys who know what -1Q0 means). What is
> -1 rem MinInf ?


The same for both floored and symmetric division, because the sign of
the operands is the same: -1. I tested this in Gforth (compiled with
gcc), and got the correct result for /mod, fm/mod, and sm/rem.


- anton
--
M. Anton Ertl Some things have to be seen to be believed
anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.