1
$\begingroup$

My textbook gives an example of truncating a signed number in two's complement from 4 bits to 3 bits. It truncates -4 to 4. I am little confused by this, because the binary representation of -4 is 1100. 1100 being truncated to 3 bits at the most significant side yields 100, which is -4 in decimal.

I am not sure, if I am missing something, but according to the book it should be 4. Am I missing something?

$\endgroup$
1
$\begingroup$

You are correct, either they truncated from a signed number to an unsigned number or they forgot a minus sign.

$\endgroup$
1
$\begingroup$

The four bit two's complement representation of $-4$ is $1100$, which you get by bit complementing $0100$ to get $1011$ then adding one to get $1100$. You are correct that in three bit two's complement notation $100$ is $-4$ decimal. You will get proper truncation any time the high order bits are the same down to the first bit you keep, as is the case here.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.