home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] Double checking re: twos complement & signed types ??

  • Subject: Re: [OCLUG-Tech] Double checking re: twos complement & signed types ??
  • From: Bart Trojanowski <bart-oclug [ at ] jukie [ dot ] net>
  • Date: Fri, 21 Sep 2007 00:30:45 -0400
* Brenda J. Butler <bjb [ at ] linuxbutler [ dot ] ca> [070920 22:44]:
> Well, the part after the comma is correct.  The part before the comma, is,
> umm, well all the numbers are stored as two's complement.

The way I understand it is that only signed numbers are in two's
complement.  If there is no signed bit, they are just binary numbers.

>                          | the same representation|
>  -8 -7 -6 -5 -4 -3 -2 -1 | 0  1  2  3  4  5  6  7 <-- (signed)
>             (unsigned) ->  0  1  2  3  4  5  6  7 | 8  9 10 11 12 13 14 15
> 
>   1  1  1  1  1  1  1  1 | 0  0  0  0  0  0  0  0 | 1  1  1  1  1  1  1  1
>   0  0  0  0  1  1  1  1 | 0  0  0  0  1  1  1  1 | 0  0  0  0  1  1  1  1
>   0  0  1  1  0  0  1  1 | 0  0  1  1  0  0  1  1 | 0  0  1  1  0  0  1  1
>   0  1  0  1  0  1  0  1 | 0  1  0  1  0  1  0  1 | 0  1  0  1  0  1  0  1

Nice.

-Bart

-- 
				WebSig: http://www.jukie.net/~bart/sig/