[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: [ANN] Lua 5.3.0 (work1) now available**
**From**: Roberto Ierusalimschy <roberto@...>
**Date**: Tue, 9 Jul 2013 10:00:17 -0300

> >If the machine does not use two complement, doing arithmetic over
> >unsigned versions of signed integers will not give the correct results
> >anyway (this is the privilege of two-complement arithmetic), so the
> >conversion back to signed is the least of the problems.
>
> I'm not sure I can follow, but arithmetic on unsigned integers
> always behaves like two's complement arithmetic, [...]
Exactly. So, if the machine does not use two complement arithmetic,
this behavior will not be the correct one for (the machine's) signed
arithmetic.
Simple example: Assume a machine using sign-and-magnitude (I will use
only four bits to simplify); then we do 3+(-2)=1. In sign-and-magnitue,
this becomes 0011+1010=0001. However, if we do the computation with
unsigneds, we have 0011+1010=1101, the wrong answer.
-- Roberto

**References**:
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Miles Bader*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***liam mail*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Miles Bader*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Tony Finch*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Philipp Janda*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Finn Wilcox*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Roberto Ierusalimschy*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Philipp Janda*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Roberto Ierusalimschy*
**Re: [ANN] Lua 5.3.0 (work1) now available, ***Philipp Janda*