Definition : Given a positive integer a, the two's complement of a relative to a fixed bit length n is the n-bit binary representation of $2^n$-a

Bit lengths of 16 and 32 are the mostly used in practice. However, because the principles are the same for all bit lengths, we use a bit length of 8 for simplicity in this discussion. For instance, because

($2^8-27)_{10} = (256-27)_{10} = 229_{10} = (128 +64+32+4+1)_{10} = 11100101_{2}$.

the 8-bit two's complement of 27 is $11100101_2$.

Source: Discrete Mathematics with Applications by Susanna Epp, p. 84

  • $\begingroup$ Unclear question. $\endgroup$ Jan 20 '16 at 12:34
  • $\begingroup$ Can you rephrase your question? $\endgroup$
    – 5xum
    Jan 20 '16 at 12:35
  • $\begingroup$ Since $2^n$ is a decimal representation and not a binary, one might think so... $\endgroup$ Jan 20 '16 at 12:36
  • $\begingroup$ Being "a decimal number" is not an inherent property of a number. A number can be written written down in different systems of notations, but it is the same number no matter how you choose to write it down (or even if you don't plan on writing it down at all). So asking whether $a$ is a decimal number in this definition does not make sense. $\endgroup$ Jan 20 '16 at 12:39
  • 1
    $\begingroup$ There are no octal numbers. There are octal representations (names) for numbers. Treating $10_{10}$ and $101_3$ as "different" is like treating the german number "drei" as different from "three." They are different ways of naming the same thing. $\endgroup$ Jan 20 '16 at 13:17

The question isn't really relevant. $a$ denotes an integer number independently of its literal representation.

$2^n$ is indeed mot probably decimal (it can't be binary and there's no reason to silently use octal, hex or another).

Anyway, provided the basis are unambiguous, you can mix the genres



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.