World's most popular travel blog for travel bloggers.

[Solved]: How many zeros should be in front of two's complement model?

, , No Comments
Problem Detail: 

The Problem Convert 256 to its 2's complement representation.

My Work

   I know that 256's representation in unsigned binary is 100000000. What I know from working with two's complement model is that the most significant digit represents the sign of the number. So in this case, 100000000 cannot be 2's complement representation as well because that would mean that the original number, 256 is negative.

   Is there a specified number of zeros I should add to the front of the binary representation? Would it be acceptable to just add one zero to the front, say 0100000000?

Asked By : committedandroider

Answered By : TEMLIB

Two's complement is a representation of a number. Using different bases, encodings, a number (as a mathematical object) can be represented in many ways.

There is no "specified number of zeros". It is rather than, if you have 10 bits, they can represent 1024 values. It can be unsigned numbers between 0 and 1023 It can be signed numbers between -512 and +511 if you use two's complement.

"0100000000" is indeed 256 both as unsigned and two's complement signed 10 bits numbers.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/41054

3.2K people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback