# 1.1 Number Systems

***

Need to know 3 types:

1. Denary - base 10 number system
2. Binary - base 2 number system
3. Hexadecimal - base 16 number system

***

## Hexadecimals

<table data-full-width="false"><thead><tr><th width="150">Letter</th><th width="314">Corresponding Denary Equiv</th><th>Corresponding Binary Equiv</th></tr></thead><tbody><tr><td>A</td><td>10</td><td>1010</td></tr><tr><td>B</td><td>11</td><td>1011</td></tr><tr><td>C</td><td>12</td><td>1100</td></tr><tr><td>D</td><td>13</td><td>1101</td></tr><tr><td>E</td><td>14</td><td>1110</td></tr><tr><td>F</td><td>15</td><td>1111</td></tr></tbody></table>

{% hint style="info" %}
To work out hex from binary, split up the binary number into sections of 4 bits each.\
To convert from denary to hex, work out the binary, then follow the above table.
{% endhint %}

### Uses

* Error codes (memory locations of an error)
* ASCII
* Assembly Language
* URLs
* MAC addresses
* IPv6 addresses
* HTML colour codes

#### MAC&#x20;

Stands for <mark style="color:yellow;">Media Access Control</mark>. It uniquely identifies a device on a network.\
It's made up of 48 bits, the first 3 hexadecimals are the manufacturers and the second half is the serial numbers.

#### HTML

Stands for <mark style="color:yellow;">HyperText Markup Language</mark>. It uses \<tags> to bracket stuff.\
It is used to represent colours of text onscreen using RGB.

***

## Binary

### Addition

If adding two digits:

| Numbers | Answer | Carry Value |
| ------- | ------ | ----------- |
| 0 + 0   | = 0    | -           |
| 0 + 1   | = 1    | -           |
| 1 + 0   | = 1    | -           |
| 1 + 1   | = 0    | 1           |

If adding three digits:

| Numbers   | Answer | Carry Value |
| --------- | ------ | ----------- |
| 0 + 0 + 0 | = 0    | -           |
| 0 + 0 + 1 | = 1    | -           |
| 0 + 1 + 1 | = 0    | 1           |
| 1 + 1 + 1 | = 1    | 1           |

{% hint style="danger" %}
Make sure to <mark style="color:red;">ADD the carry value to the sum</mark>. Otherwise, your answer will be incorrect.
{% endhint %}

### Overflow

This occurs when bits are 'pushed' off the grid. An overflow error can occur.

As an example:

```
Adding two 8 bit numbers:

  0 1 1 0 1 1 1 0
  1 1 0 1 1 1 1 0
  ---------------
1 0 1 0 0 1 1 0 0

We have 9 bits in the answer.
```

Just using 8 bits in the above example would give us an incorrect answer. The generation of the 9th bit is a clear indication that the sum has exceeded the value of 255 as that is the maximum of an 8 bit number. This is an overflow error because an 8 bit computer cannot store that answer.&#x20;

{% hint style="info" %}
This is why calculators sometimes come up with an error when adding or multiplying stupidly large numbers.
{% endhint %}

### Logical Shifts

Computers can do a logical binary shift to either the right or the left. When doing this, we can cause an overflow error if the last or first bit is a 1. The right most bit is referred to as the LSB (least significant bit) and left most bit is the MSB (most significant bit).It's important to note that <mark style="color:yellow;">doing a shift will CHANGE the value of the number</mark>.

{% hint style="info" %}
If you do a shift to the left  ->  multiply the number by 2

If you do a shift to the right  ->  divide the number by 2
{% endhint %}

### Two's Complement

This is used when we want negative numbers. We <mark style="color:yellow;">change the most left bit to a negative value</mark>. As an example, if we have an 8 bit number, we will change the MSB (128) to -128.

When applying this rule to a binary number, the left most bit always determines whether the number is positive or negative. <mark style="color:yellow;">If a 1 is there, the number is negative. If a 0 is there, the number is positive.</mark>

***

## Exam Questions

{% embed url="<https://cdn.savemyexams.com/pdfs/YtbGGKOAsCmST2zk.pdf>" %}
COPYRIGHT -> SAVEMYEXAMS
{% endembed %}

***
