Show the binary representation of decimal 417. Then show the one’s complement of 417, and the two’s complement of 417.
What will be an ideal response?
Binary:
512 256 128 64 32 16 8 4 2 1
256 128 64 32 16 8 4 2 1
(1*256)+(1*128)+(0*64)+(1*32)+(0*16)+(0*8)+(0*4)+(0*2)+
(1*1)
110100001
One’s complement: 001011110
Two’s complement: 001011111
Check: Original binary number + its two’s complement
110100001
001011111
---------
000000000
You might also like to view...
Convert1710 to an 8-bit integer in sign-and-magnitude format:
a. 100012 b. 100100012 c. 000100012 d. 1100012
It is an error to call the delete operator on a pointer a second time. Consider what happens if there is memory allocated on the free store for a class, a destructor, and initializing constructors have been defined, but no copy constructor was defined. Now suppose a function is called that has call-by-value parameters. Why does the program either die in the middle or give a segmentation fault?
What will be an ideal response?