You can have an number as your base system. However, binary, i.e. base 2, is extremely advantageous in the case of computing, as a given bit (binary digit), can be represented by a signal being on or off. Basic binary decimal representation is what we call an unsigned integer. e.g. is the following is decimal

Unsigned Integer

Mathematical base 2.

Signed Integer

Base 2, but the sign needs to be encoded.

Signed-Magnitude (Naive Approach)

Leading 1 encodes sign. Remaining bits encode magnitude. Very ugly for math.

2’s Complement

Nonnegative integers represented the same way as unsigned integers. Negative integers “wrap around”, so 1 + the maximum positive integer wraps around to the smallest negative integer. Avoids 0 having two representations.

Decimal to Binary Conversion

Long way
  1. Find largest power of 2 that fits into the number
  2. Note that power of 2
  3. Subtract from number
  4. Repeat until all bits noted
Faster way
  1. Note parity
  2. Integer divide by 2
  3. Repeat
  4. Odd 1, Even 0
  5. Bit produced in reverse order

Addition and Subtraction

Use 2’s Complement signed representation

  • When adding and , just add them 😳
  • When subtracting from just add and