Search code examples
integerhardwaresignedtwos-complement16-bit

Is a signed 16-bit integer the same as a two's complement 16-bit integer?


I know the difference between one's and two's compliment integers, however I'm uncertain on whether a signed 16-bit integer is the same as either or both of those.

Hopefully an easy yes/no question.


Solution

  • Signed integer only means that the type can store negative values. It doesn't say anything about signed type representation which can be 1's complement, 2's complement or sign-magnitude... Even C and C++ standard nowadays don't force the use of 2's complement. But a signed type obviously can't be both 1's and 2's complement at the same time

    In modern systems 2's complement is used exclusively (probably except some network devices) but older systems that use other signed representations exist, for example the UNISYS 2200 series