# Data Representation: Understanding Number Bases(AQA)

### Number Bases: Decimal and Binary

#### Decimal (Base 10)

• The decimal system is the standard system for denoting integer and non-integer numbers. It is based on 10 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

• The decimal system is used in everyday counting and arithmetic.

#### Example:

• 345 in decimal represents:

• 3 × 10 2 + 4 × 101 + 5 × 100

#### Binary (Base 2)

• The binary system is a base-2 numeral system which uses only two symbols: 0 and 1.

• Computers use the binary system to represent all data and instructions because it aligns with the digital nature of their hardware (transistors that are either on or off).

#### Example:

• 1101 in binary represents:

• = 1 × 2 3 + 1 x 2 2 + 0 x 2 2 + 1 x 2 0

= 8 + 4 + 0 + 1

= 13

#### Understanding Binary in Computing

• Representation: All data and instructions in a computer are represented using binary code.

• Binary Digits: Each binary digit (bit) is a 0 or 1.

### Converting Between Binary and Decimal

#### Binary to Decimal Conversion

• Method: Sum the products of each binary digit (bit) and its corresponding power of 2.

• Steps:

1. Write down the binary number.

2. List the powers of 2 from right to left, starting with 2^0.

3. Multiply each bit by its corresponding power of 2.

4. Sum the results.

#### Example:

• Binary: 1011

• Calculation:

• 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 1 x 2^0

= 8 + 0 + 2 + 1

= 11

• Decimal: 11

#### Decimal to Binary Conversion

• Method: Divide the decimal number by 2 and record the remainder. Repeat the process with the quotient until it is 0, then read the remainders in reverse order.

• Steps:

1. Divide the decimal number by 2.

2. Record the remainder (0 or 1).

3. Use the quotient as the new number to divide by 2.

4. Repeat until the quotient is 0.

5. The binary number is the remainders read from bottom to top.

#### Example:

• Decimal: 19

• Calculation:

• 19 / 2 = 9 remainder 1

• 9 / 2= 4 remainder 1

• 4 / 2= 2 remainder 0

• 2 / 2= 1 remainder 0

• 1 / 2= 0 remainder 1

• Binary: 10011

### Number Base: Hexadecimal (Base 16)

• The hexadecimal system is a base-16 numeral system which uses sixteen symbols: 0-9 and A-F (where A = 10, B = 11, C = 12, D = 13, E = 14, F = 15).

• Hexadecimal is often used in computing as a more human-friendly representation of binary-coded values.

#### Example:

• Decimal:

• 2 × 16 1 + F x 16 0

= 2 x 16 + 15 x 1

= 32 + 15

= 47

### Converting Between Decimal and Hexadecimal

• Method: Divide the decimal number by 16 and record the remainder. Repeat the process with the quotient until it is 0, then read the remainders in reverse order.

• Steps:

1. Divide the decimal number by 16.

2. Record the remainder.

3. Use the quotient as the new number to divide by 16.

4. Repeat until the quotient is 0.

5. The hexadecimal number is the remainders read from bottom to top.

#### Example:

• Decimal: 254

• Calculation:

• 254 / 16 = 15 remainder 14 (E in Hex)

• 15 / 16 = 0 remainder 15 (F in Hex)

• Method: Sum the products of each hexadecimal digit and its corresponding power of 16.

• Steps:

1. Write down the hexadecimal number.

2. List the powers of 16 from right to left, starting with 16^0.

3. Multiply each hex digit by its corresponding power of 16.

4. Sum the results.

#### Example:

• Calculation:

• 3 x 16 1 + C x 16 0

= 3 x 16 + 12 x 1

= 48 + 12

= 60

• Decimal: 60

### Converting Between Binary and Hexadecimal

• Method: Group the binary digits into sets of four (starting from the right), convert each group to its hexadecimal equivalent.

• Steps:

1. Write down the binary number.

2. Starting from the right, group the binary digits into sets of four.

3. Convert each group of four binary digits to their hexadecimal equivalent.

#### Example:

• Binary: 10111010

• Grouping: | 1011 | 1010 |

• Conversion: 1011 (B), 1010 (A)

• Method: Convert each hexadecimal digit to its four-digit binary equivalent.

• Steps:

1. Write down the hexadecimal number.

2. Convert each hex digit to its four-bit binary equivalent.

#### Example:

• Conversion: 3 (0011), C (1100)

• Binary: 00111100

### Why Hexadecimal is Used in Computer Science

#### Key Reasons:

1. Compact Representation: Hexadecimal provides a more compact and readable form of binary numbers, which are often long and difficult to interpret.

2. Ease of Conversion: Conversion between binary and hexadecimal is straightforward, as one hexadecimal digit corresponds exactly to four binary digits.

3. Error Reduction: Hexadecimal reduces the likelihood of errors in reading and writing long binary numbers.