binary - Two's Complement of a number and its negative number difference? -


so told two's complement used find complement of number , used complement positive numbers (i.e positve --> negative conversion) got example in book asks me following :

express 23, -23, , -9 in 8-bit binary two’s complement form

now mean? 23 means -23 in binary , -23 means 23 ?

sorta confused on there

2's complement used represent negative numbers, in turn, can used subtraction.

23 = 00010111b 

to -23 (2's complement of 23), flip bits, , add 1:

 11101000b + 1 =11101001b (-23) 

-9 2's complement of 9. 9 is

00001001b 

so -9 is

11110111b (flipping , add +1) 

see here


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -