---
description: Learn about number sets, bases and conversions.
---

# Number Systems

### Numbers for Counting

When we count objects, we use special symbols like $$0,1,2,3,4,5,6,7,8,9$$. Nowadays, these numbers are generally accepted around the world, even though some languages have their own symbols to represent the same quantities like Chinese & Arabic.&#x20;

These quantities are known as **Natural Numbers/Counting Numbers**.

For numbers to be qualified as Natural Numbers, they must be:

* **In Order:** Each number in the set must be greater than the previous number.
* **Counting Numbers:** The numbers must be usable for counting. Like _5 apples in a bag._
* **Infinite Set:** There should be no limit to the amount of numbers the set can hold.&#x20;
* **No fractions or decimals:** Natural numbers cannot be expressed as fractions or decimals. They are discrete and do not include portions of a whole.

> In **AQA**, zero is also a natural number, even though the scientific community doesn't really agree.

The following set is used to refer to **natural numbers**:

$$
\mathbb{N} = \{0,1,2,3, ...\}
$$

### Integers

Any positive or negative whole number is called an **integer**. The following set is used to describe integers:

$$
\mathbb{Z} = \{..., -2, -1, 0, 1, ..\}
$$

### Rational Numbers

These are all numbers that can be expressed as fractions and ratios. They Include:

* All values within the **integer** set.
* Recurring values such as `0.3333333333 (1/3)`

$$
\mathbb{Q} = \{..., 2/1, 2/2, 2/3, 2/4, ...\}
$$

$$
\mathbb{Q} = \{...,2,1,0.6,0.5, ...\}
$$



### Irrational Numbers

Some numbers cannot be described exactly as a fraction, thus making them irrational. The decimal values of these numbers are endless.&#x20;

Here are a few examples of irrational numbers: $$\pi, e, \sqrt{2}, \sqrt{3}$$

### Real Numbers

All rational and irrational numbers are considered to be real numbers, they are used for measurement. The set is represented via the mathematical symbol $$\mathbb{R}$$.

### Ordinal Numbers

This is when numbers are used to represent rank or position of an entity, rather than representing quantities. An example of this would be "_Have you completed the **1st** assignment?_".

### Pictorial Summary &#x20;

<figure><img src="https://1290419884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAV4XdLTwIn73oe6UPZsz%2Fuploads%2FuBI2QwkRKuNo2BXgdxzJ%2Fimage.png?alt=media&#x26;token=f4474a5a-f3e1-47d6-9daa-c561d30df771" alt="Visual Representation of Numerical Sets."><figcaption><p>A visual representation of numerical sets | (Source: Momentrix, 2024)</p></figcaption></figure>

## Number Systems

We use a number system called base[^1] 10 (also known as Denary[^2]) for our calculations, as we count from 1 to 10. The reason why this base may have been chosen by our ancestors could be due to them having a total of 10 fingers.&#x20;

### Binary

Computers use base 2 (also known as Binary) due to it being easier to process and taking less space.&#x20;

Below is a list of commonly used binary values.

| Denary | Binary (unsigned 8-bit) |
| :----: | :---------------------: |
|    1   |         00000001        |
|    2   |         00000010        |
|    3   |         00000011        |
|    4   |         00000100        |
|    5   |         00000101        |
|    6   |         00000110        |
|    7   |         00000111        |
|    8   |         00001000        |
|    9   |         00001001        |
|   10   |         00001010        |

#### Two's Complement

We can convert normal binary numbers into their negative values using two's complement. To do this you firstly need to turn the largest place value of the binary number into negative, and then use 1s and 0s accordingly to reach the negative representation of that value.

Here is an example: _Converting the number 5 into -5_&#x20;

**5:**

<table data-full-width="false"><thead><tr><th align="center">8</th><th align="center">4</th><th align="center">2</th><th align="center">1</th></tr></thead><tbody><tr><td align="center">0</td><td align="center">1</td><td align="center">0</td><td align="center">1</td></tr></tbody></table>

**-5:**

<table data-full-width="false"><thead><tr><th align="center">-8</th><th align="center">4</th><th align="center">2</th><th align="center">1</th></tr></thead><tbody><tr><td align="center">1</td><td align="center">0</td><td align="center">1</td><td align="center">1</td></tr></tbody></table>

The method above seems long & difficult, so we can use a short trick: To convert any binary number into negative, just go to the first value that is **1**, keep it the same and all values behind it the same, and inverse all values that come after it.

#### Adding & Subtracting Binary Values

We add binary numbers just like we do with denary numbers, there are only two values in binary, which makes adding them easier. If there are two resultant digits, carry the one on the left. Here are things to keep in mind:

```wolfram
0 + 0 = 00
0 + 1 = 01
1 + 0 = 01
1 + 1 = 10
1 +1 + 1 = 11
```

To **subtract** binary values, just use two's complement to turn the subtracting value negative, then just add the numbers together. This works because one plus and a negative makes a negative, like `5+-3 = 5-3 = 2`

_Here's a video about adding/subtracting in binary:_

{% embed url="https://youtu.be/C5EkxfNEMjE" fullWidth="false" %}
Adding and Subtracting binary numbers.
{% endembed %}

#### Multiplication in binary

Multiplication in binary is just like normal multiplication. Here's a video explanation:

{% embed url="https://youtu.be/hK1OYxYpwEc" %}
Binary Multiplication
{% endembed %}

### Hexadecimal

Base 16 (also known as Hex[^3]) is a very common numerical system used widely by developers. The first 10 symbols of hex are the same as base 10, however it also uses ABCDEF. So in total there are 16 symbols.&#x20;

Below is an example of converting the hex number 3F5 into denary.

<figure><img src="https://1290419884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAV4XdLTwIn73oe6UPZsz%2Fuploads%2FvUGB0LnO8ZX7476FD30L%2Fimage.png?alt=media&#x26;token=8358ed35-f4da-46e9-a81b-7d1356bf4776" alt=""><figcaption></figcaption></figure>

The reason why developers use hex is that it is compact and uses less memory, so more numbers can be stored onto the computer. Also, less digits are required represent large numbers, this means that less space will be taken on display monitors when looking at the numbers. Also, the fact that the numbers look short, it makes it easier for the developers to memorise the numbers and quickly recall them, and it also helps them reduce confusion.

_Usage of Hex:_

* _Memory addresses_
* _MAC addresses_
* _Unicode characters_
* _Colour Codes_

You can convert hexadecimal into binary to perform mathematical operations.

### Representation

To represent different bases, you can add a subscript under the value with the number of the base.&#x20;

Base 10: $$123_{10}$$

Base 2: $$1111011_2$$

Base 16: $$7B_{16}$$

### Conversion

{% embed url="https://youtu.be/D_YC6DSPpQE" %}
Converting **hex** to **binary**.
{% endembed %}

{% embed url="https://youtu.be/tSLKOKGQq0Y" %}
Converting **binary** to **hex**
{% endembed %}

[^1]: A base is the number of symbols used to construct values

[^2]: Decimal Number System

[^3]: Hexadecimal
