0

Singed numbers in memory are represented in such a way that the first bit defines a sign. I've taken a char as an example (and as a simpliest type to type), but this concerns other signed datatypes as well.

14 = 00001110

Since the first number is positive, the first bit is 0. The max signed char is represented like this:

127 = 01111111

It seems to be reasonable to simply change the first bit to make it negative, but then the other 7 bits still can only represent the number of 127 (if do not take the first bit into account). How then is it possible to store -128?

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
Kaiyaha
  • 448
  • 3
  • 9

1 Answers1

2

-128 would be represented as 10000000 (which looks like -0, but that would be a redundant way of representing 0).

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101