Related articles |
---|
[2 earlier articles] |
Re: New Book: The School of Niklaus Wirth gdemont@my-deja.com (2000-11-16) |
Re: New Book: The School of Niklaus Wirth jerrold.leichter@smarts.com (Jerry Leichter) (2000-11-17) |
Re: New Book: The School of Niklaus Wirth fjh@cs.mu.OZ.AU (2000-11-19) |
Re: New Book: The School of Niklaus Wirth jerrold.leichter@smarts.com (Jerry Leichter) (2000-11-21) |
Re: types, was New Book: The School of Niklaus Wirth joachim_d@gmx.de (Joachim Durchholz) (2000-11-25) |
Re: types, was New Book: The School of Niklaus Wirth jerrold.leichter@smarts.com (Jerry Leichter) (2000-11-30) |
Re: types, was New Book: The School of Niklaus Wirth anton@mips.complang.tuwien.ac.at (2000-12-01) |
Re: types, was New Book: The School of Niklaus Wirth jenglish@flightlab.com (2000-12-03) |
From: | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
Newsgroups: | comp.compilers |
Date: | 1 Dec 2000 13:36:57 -0500 |
Organization: | Institut fuer Computersprachen, Technische Universitaet Wien |
References: | 00-11-046 00-11-082 00-11-120 00-11-122 00-11-133 00-11-141 00-11-152 00-11-165 |
Keywords: | types |
Posted-Date: | 01 Dec 2000 13:36:57 EST |
Jerry Leichter <jerrold.leichter@smarts.com> writes:
>For *division*, however, things break down: 1/-1 is -1 in signed
>arithmetic, but 0 in unsigned arithmetic. The unsigned form gives you
>the division in the ring of integers mod 2^n,
If you mean "ring of (integers mod 2^n)", then you are wrong. E.g.,
3*6=2 (mod 16)
i.e.,
2/3=6 (mod 16)
In contrast, the integer division in all programming languages I know
gives 0 for 2/3.
>I don't remember off-hand how multiplication works out
Multiplication is just like addition: unsigned multiply also serves as
2s-complement multiply, unless you try to mix precisions (i.e., you
need different signed and unsigned multiplies for 32bit*32bit=64bit).
>> You may be confusing this with C, where signed arithmetic overflow
>> has undefined behaviour (probably because modulo arithmetic for
>> signed integers was considered too unimportant and too variant to be
>> a useful part of the standard).
>
>Actually, this has to do with what hardware can implement cheaply.
Yes. In particular there is probably no way to define a result for
signed arithmetic overflow that can be implemented cheaply on
2s-complement, 1s-complement, and sign-magnitude machines.
- 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
Return to the
comp.compilers page.
Search the
comp.compilers archives again.