|[2 earlier articles]|
|Re: New Book: The School of Niklaus Wirth email@example.com (2000-11-16)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (Jerry Leichter) (2000-11-17)|
|Re: New Book: The School of Niklaus Wirth email@example.com.OZ.AU (2000-11-19)|
|Re: New Book: The School of Niklaus Wirth firstname.lastname@example.org (Jerry Leichter) (2000-11-21)|
|Re: types, was New Book: The School of Niklaus Wirth email@example.com (Joachim Durchholz) (2000-11-25)|
|Re: types, was New Book: The School of Niklaus Wirth firstname.lastname@example.org (Jerry Leichter) (2000-11-30)|
|Re: types, was New Book: The School of Niklaus Wirth email@example.com (2000-12-01)|
|Re: types, was New Book: The School of Niklaus Wirth firstname.lastname@example.org (2000-12-03)|
|From:||email@example.com (Anton Ertl)|
|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|
|Posted-Date:||01 Dec 2000 13:36:57 EST|
Jerry Leichter <firstname.lastname@example.org> 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)
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.
M. Anton Ertl Some things have to be seen to be believed
email@example.com Most things have to be believed to be seen
Return to the
Search the comp.compilers archives again.