El martes, 27 de enero de 2015, Cathey, Jim <[email protected]> escribió:

> Because mathematically, differences are *always* signed!
>
>
>
>                 2 - 1 ==  1
>
>                 1 - 2 == -1
>

In modulo arithmetic , addition and substraction are the same for both
unsigned and signed operands.

Assume you have two 32-bit operands a and b. Let's assume a=1 and b=2.

The result of a-b is always 0xffffffff regardless of whether a and b are
signed or unsigned.

Signedness *will* be relevant when you need to compare with another value:

If the operand is unsigned, 0xffffffff > 0
If the operand is signed, 0xffffffff (-1) < 0

Guillermo


-- 
Guillermo Rodriguez Garcia
[email protected]
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to