Re: Rounding with Div and Mod operators

Johan Persson <johan.persson@mbox319.swipnet.se>
16 May 1999 15:27:18 -0400

          From comp.compilers

Related articles
[2 earlier articles]
Re: Rounding with Div and Mod operators ucapjab@ucl.ac.uk (Jonathan Barker) (1999-05-16)
Re: Rounding with Div and Mod operators nr@labrador.cs.virginia.edu (Norman Ramsey) (1999-05-16)
Re: Rounding with Div and Mod operators guerby@acm.org (Laurent Guerby) (1999-05-16)
Re: Rounding with Div and Mod operators anton@mips.complang.tuwien.ac.at (1999-05-16)
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)
[5 later articles]
| List of all articles for this month |
From: Johan Persson <johan.persson@mbox319.swipnet.se>
Newsgroups: comp.compilers
Date: 16 May 1999 15:27:18 -0400
Organization: Compilers Central
References: 99-05-039
Keywords: arithmetic, design

William Rayer wrote:
> My question is: which rounding system is preferred and does it matter?


My experience of using int, mod and div operators are that if they round
towards zero they are useless if you don't know that you only are
dealing with positive OR negative numbers. I usually write my own
functions that round downwards and use them instead of the built-in
operators. I have never come across a case where rounding towards zero
is the preferred choice.


/Johan


Johan Persson
johan.persson@mbox319.swipnet.se


Post a followup to this message

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