I'm just starting to learn about representing numbers in sign-and-magnitude and two's complement, and both as signed binary integers two's complement if representing a negative number I should invert all bits and add one, while sign-and-magnitude represents negative numbers with the first bit as a sign bit, but is it possible whether I can tell if a number is represented in sign-and magnitude or two's complement from just looking at it?
-
$\begingroup$ Only looking at binary you cannot even say is it signed or unsigned. Everything depends on interpretation. This is why we need types. $\endgroup$– zkutchJun 19, 2022 at 6:08
-
$\begingroup$ (Only looking at a binary representation of an integer I couldn't tell little endian from big endian, unsigned from signed. And in addition to signed and two's complement, there's biased and some more representations that have fallen out of favour (for a reason).) Interpretation is the difference. $\endgroup$– greybeardJun 19, 2022 at 8:24
1 Answer
Every string of bits can be interpreted both as a two's complement or a sign-and-magnitude number. So the answer is clearly no.
[Usually, sign-and-magnitude allow negative zero; if not in your context, then you could say that $100\cdots0$ is a two's complement number, anyway.]