Cheap and Secure Web Hosting Provider : See Now

Is it possible to compute -12 (decimal) in 4 bits binary

, , No Comments
Problem Detail: 

This is what I have so far

1 1 0 0

Switch values by 2s Complement

0 0 1 1 + 1


0 1 0 0

Asked By : Fred

Answered By : DylanSp

No, it's not possible, at least using the standard representations. An unsigned $n$-bit number can represent any integer in the interval $[0, 2^{n} - 1]$. A signed $n$-bit number using two's complement can represent integers in the interval $[-2^{n - 1}, 2^{n - 1} - 1]$. With $n = 4$, that gives an interval of $[-8, 7]$, which obviously doesn't include $12$. One's complement can use $n$ bits to represent the interval $[-(2^{n - 1} - 1), 2^{n - 1} - 1]$, giving the interval $[-7, 7]$ for four bits, which also doesn't work. You'd have to contrive a nonstandard representation to represent $-12$ in four bits.

Best Answer from StackOverflow

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

3200 people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback