Number Systems and Binary Notes

Number System & Computers & Binary

  • Computers use binary because data is processed using logic gates with two states.

  • The binary number system has two digits (1/0), representing different states (1 = on, 0 = off).

  • All data must be converted to binary for a computer to understand and process it.

  • Converting to binary allows computers to process data at incredible speeds, perform complex calculations, and efficiently store vast amounts of data.

  • Secondary storage uses binary; magnetic hard drives use North and South polarity to represent 1 or 0.

  • Optical disks interpret light hitting a flat area (land) as 1 and light hitting a bump (pit) as 0.

Worked Example

  • Computers process data using logic gates that have only two states (1/0).

Number Systems: Denary, Binary & Hexadecimal

Denary

  • Denary is a base-10 number system made up of 10 digits (0-9).

  • Humans use the denary system for counting, measuring, and performing math calculations.

  • Combinations of the 10 digits can represent any number.

  • Example: (3×1000)+(2×100)+(6×10)+(8×1)=3268(3 \times 1000) + (2 \times 100) + (6 \times 10) + (8 \times 1) = 3268

Binary

  • Binary is a base-2 number system made up of two digits (1 and 0).

  • Each digit has a weight factor of 22 raised to a power.

  • Each time a new digit is added, the column value is multiplied by 22.

  • Combinations of the 2 digits can represent any number.

  • Example: Binary 1100 = (1×8)+(1×4)=12(1 \times 8) + (1 \times 4) = 12

Hexadecimal

  • Hexadecimal is a base-16 number system made up of 16 digits: 10 numbers (0-9) and 6 letters (A-F).

  • Each digit has a weight factor of 1616 raised to a power.

  • One hexadecimal digit can represent four bits of binary data.

Converting Between Binary & Denary

Denary to Binary Conversion

  • Write out a binary number line.

  • Find the first column heading with a value larger than the denary value you are converting.

  • Write down each column heading to the right (not including the largest heading) until you reach 1.

Method 2
  • Example:

    • 142 divided by 2 = 71, remainder 0

    • 71 divided by 2 = 35, remainder 1

    • 35 divided by 2 = 17, remainder 1

    • 17 divided by 2 = 8, remainder 1

    • 8 divided by 2 = 4, remainder 0

    • 4 divided by 2 = 2, remainder 0

    • 2 divided by 2 = 1, remainder 0

    • 1 divided by 2 = 0, remainder 1

  • Read the remainders from bottom to top to get the binary number: 10001110.

Examiner Tips and Tricks
  • Read the question carefully to check for how many bits are expected in your answer.

  • If the question requires an 8-bit answer and a 6 bit answer has been given, add 2 extra 0s to the start of the answer.

  • Denary 45 is 101101 in 6-bit binary and 00101101 in 8-bit binary.

Binary to Denary Conversion

  • Count how many bits make up the value.

  • Write out the column headings for the number of bits given from right to left.

  • Add together any column heading with a value of 1 in the column.

Binary to hexadecimal and hexadecimal to binary

Example 1
  • 101111100001

  • First split this up into groups of 4 bits:

    • 1011 1110 0001

  • Then, find the equivalent hexadecimal digits:

    • B E 1

Example 2
  • 10000111111101

  • First split this up into groups of 4 bits:

    • 10 0001 1111 1101

  • The left group only contains 2 bits, so add in two 0s:

    • 0010 0001 1111 1101

  • Now find the equivalent hexadecimal digits:

    • 2 1 F D

Hexadecimal to denary and Denary to hexadecimal

Example 1
  • Convert the hexadecimal number, 45A, into denary.

  • Multiply each hex digit by its heading value:

    • 256 16 1

    • 4 5 A

    • (4 x 256 = 1024) (5 x 16 = 80) (10 x 1 = 10) (NOTE: A = 10)

  • Then add the three totals together (1024 + 80 + 10) to give the denary number:

    • 1114

Example 2
  • Convert the hexadecimal number, C8F, into denary.

  • Multiply each hex digit by its heading value:

    • 256 16 1

    • C 8 F

    • (12 x 256 = 3072) (8 x 16 = 128) (15 x 1 = 15) (NOTE: C=12, F = 15)

  • Then add the three totals together (3072 + 128 + 15) to give the denary number:

    • 3215

Uses of Hexadecimal

  • Hexadecimal is often preferred when working with large values in Computer Science.

  • It takes fewer digits to represent a given value in hexadecimal than in binary.

  • 1 hexadecimal digit corresponds 4 bits (one nibble) and can represent 16 unique values (0-F).

  • It is beneficial to use hexadecimal over binary because:

    • The more bits there are in a binary number, the harder it makes for a human to read

    • Numbers with more bits are more prone to errors when being copied.

Uses of Hexadecimal System:
  1. Error codes are often shown as hexadecimal values; numbers refer to the memory location of the error.

  2. A MAC address is usually made up of 48 bits, shown as 6 groups of two hexadecimal digits.

  3. An IPv6 address is a 128-bit number broken down into 16-bit chunks, represented by a hexadecimal number.

  4. A typical hexadecimal color code consists of 6 hexadecimal digits, equivalent to 24 digits in binary.

  5. URLs can only contain standard characters (a-z and A-Z), numbers (0-9), and some special symbols; other characters are converted into a hexadecimal code prefixed with a % sign.

Addition of binary numbers

binary digit

carry

sum

0+0+0

0

0

0+0+1

0

1

0+1+0

0

1

0+1+1

1

0

1+0+0

0

1

1+0+1

1

0

1+1+0

1

0

1+1+1

1

1

Example 1
  • Add 00100111 and 01001010

  • Carry values are 111

  • Sum values are 01110001

  • Answer: 01110001

    • Column 1: 1+0= 1 no carry

    • Column 2: 1+1 = 0 carry 1

    • Column 3: 1+0+1 = 0 carry 1

    • Column 4: 0 + 1 + 1 = 0 carry 1

    • Column 5: 0 + 0 + 1 = 1 no carry

    • Column 6: 1+0 = 1 no carry

    • Column 7: 0+1 = 1 no carry

    • Column 8: 0 +0 = 0 no carry

Overflow & Binary Addition

What is an overflow error?
  • An overflow error occurs when the result of a binary addition exceeds the available bits

Example 3

*Add 01101110 and 11011110 (using 8 bits)
*Carry: 111111
*Sum: 1 01001100