Numbering Systems and Data Conversion
Weighted positional notation
Each digit is multiplied by the base raised to its position. Binary is base 2, octal base 8, hexadecimal base 16. Because 8 = 2^3 and 16 = 2^4, one octal digit equals exactly three bits and one hex digit exactly four bits: group bits outwards from the radix point to convert. Memorise the sixteen hex digits and their 4-bit patterns.
Negative numbers and codes
Two's complement is standard: invert every bit, then add 1. It has one zero and makes subtraction the same operation as addition. For n bits the range is -2^(n-1) to +2^(n-1)-1, so 8 bits hold -128 to +127. One's complement and sign-and-magnitude are distractors. BCD stores one decimal digit per nibble, so 0x25 in BCD is twenty-five, not thirty-seven. Gray code changes one bit per step and suits position encoders. Odd parity, used on ARINC 429, makes the total count of 1s odd.
Conversion and sampling
An n-bit converter has 2^n steps and a resolution of full-scale range divided by 2^n. Sampling must exceed twice the highest signal frequency (Nyquist) or aliasing results.
Traps
Confusing resolution with accuracy, treating BCD as ordinary binary, and forgetting the sign when a two's complement value has its most significant bit set.
Worked example
Take 1011 0110. Unsigned it is 128+32+16+4+2 = 182. As two's complement it is negative: invert to 0100 1001 and add 1, giving 0100 1010 = 74, so the value is -74. In hex, 1011 = B and 0110 = 6, so the byte is 0xB6.