November 13, 2015
On Friday, 13 November 2015 at 10:20:53 UTC, Don wrote:
> On Friday, 13 November 2015 at 09:37:41 UTC, deadalnix wrote:
>> On Friday, 13 November 2015 at 09:33:51 UTC, John Colvin wrote:
>>> I don't understand what you think is so complicated about it?
>
>>> After arithmetic operations f is applied
>>> signed: f(v) = ((v + 2^(n-1)) mod (2^n - 1)) - 2^(n-1)
>
> Complicated in the sense that: when are those semantics useful? The answer of course, is, pretty much never. They are very bizarre.

They are 99% useless, I agree. The only good argument for them I can think of is that it's a faithful mapping to the underlying machine.
November 13, 2015
On Friday, 13 November 2015 at 09:33:51 UTC, John Colvin wrote:
> unsigned: f(v) = v mod 2^n - 1
> signed: f(v) = ((v + 2^(n-1)) mod (2^n - 1)) - 2^(n-1)

I guess you meant mod 2^n in both cases...

If you look at how Mathematics deals with this issue, there is simply no signed or unsigned arithmetic modulo n, because they are exactly the same. There are only separate types in programming languages because the comparison operators are defined differently on them.

Mathematicians don't define comparison on modular rings, because it is not possible to do so in a way that is consistent with the usual rules anyway (e.g. x+1 > x is always false for some x).

November 13, 2015
On Friday, 13 November 2015 at 12:06:43 UTC, Matthias Bentrup wrote:
> On Friday, 13 November 2015 at 09:33:51 UTC, John Colvin wrote:
>> unsigned: f(v) = v mod 2^n - 1
>> signed: f(v) = ((v + 2^(n-1)) mod (2^n - 1)) - 2^(n-1)
>
> I guess you meant mod 2^n in both cases...

haha, yes, sorry.
1 2 3
Next ›   Last »