Hacker News new | ask | show | jobs
by umanwizard 759 days ago
Assuming 4-byte integers,

0000 is 0

0001 is 1

0010 is 2

0011 is 3

0100 is 4

0101 is 5

0110 is 6

0111 is 7

1111 is -1

1110 is -2

1101 is -3

1100 is -4

1011 is -5

1010 is -6

1001 is -7

1000 is -8

The highest bit is always 1 when the sign is negative.

2 comments

Too late to edit, but I meant 4-bit, not 4-byte.
What is the edit window in hours?
Useful example, thanks.