Reputation: 41
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.
Upvotes: 1
Views: 687
Reputation: 41753
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
Upvotes: 2
Reputation: 199
Yes, saying an integer is signed is the same as saying it's using two's complement representation on your standard computer.
Upvotes: 1