Number systems
Review these topic from S1:
Signed integers
To denote signed integers, there are 3 approaches.
- Sign-and-magnitude
- One’s complement
- Two’s complement
Sign-and-magnitude
MSB denotes the sign. Remaining bits denote the magnitude.
2 problems with this representation:
- Two zeros (
and ) - Arithmetic is cumbersome
Special formats
BCD
Short for binary coded decimal. Each digit is represented by a fixed set of bits. Usually in length 4 or 8. Only 10 of the available representations are used. The remaining ones are not valid.
Gray codes
Aka. reflected binary. An ordering of the binary numeral system such that two successive values differ only by 1 bit. Named after Frank Gray.
If two adjacent states have more than 1 bit changed (eg: 3 and 4), then the value transition might take some noticable time and could lead to issues.
A gray code is said to be cyclic, if the first and last numbers also differ by a bit.