CS-iGCSE-CIE-Notes

Number Systems

Back to Topic 1 Index Page


Table of Contents


Computers use binary due to its simplicity and efficiency; it’s easy to detect electrical signals, and compatible with logic gates.

Binary

Denary

Hexadecimal

Bits & Bytes

0 or 1 represents true or false, on or off, or open or closed (the position of a gate).

Either 0 or 1 = Bit

A sequence of 8 binary bits = Byte

Bytes can store 256 different values. One byte can represent the denary values 0-255.

4 bytes can store 256^4 different values or 4 billion values.

16 bytes can store 256^16.

All values are integers. They are also interchangeable, and can translate between number systems.

Two’s complement:

It can convey negative values. The most significant bit (128) is negative.

In two’s complement, 01111111 is equal to +(127). 11111111 = -(1).

Shifts:

Move all values up or down. During a left shift, all bits move up by one place, and the most significant bit is lost. This can occur multiple times, and any empty positions are replaced with zero. However, there is a limit. Eventually the result will be incorrect, or the number will be too large. Additionally, only integer values can be stored in binary.

An overflow error occurs when a number is too large to be stored in an 8-bit register (greater than 255).

Computers have a limit for the values that can be stored. For example, if the limit is 16-bit, it can only store 16-bit integers.

Nibble:

A nibble is half a byte. They are split into upper (left) and lower (right) nibbles. The maximum value a nibble can store is 15 (16 different numbers).

Hexadecimal = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f

Real-life uses of hexadecimal:

MAC (media access control) addresses are assigned by the manufacturer of the device. IP (internet protocol) addresses are assigned by the internet service provider. Once you connect to the internet an IP address is assigned to you.

MAC addresses are made up of 48 bits. It identifies the NIC of the device.

NN:NN:NN:DD:DD:DD

N = number of manufacturer

D = serial number

IP - Internet protocol address

IPv4 is a 32-bit address developed in 1981. There are 4.3 billion IPv4 addresses that use dot-decimal notation.

IPv6 is a 128-bit address developed in 1998 with billions more addresses. These addresses use hexadecimal notation.

\

28/9/2022

Review:
Bit - A value of either 0 or 1

Byte - A 8-bit binary sequence

Hexadecimal - Base 16. Used to represent binary. It is much easier for humans to understand than binary. It is solely for development purposes (makes sequences more recognisable and makes fewer human errors)

  1. 00001001

1 + 8 = 9

  1. 00010101

1 + 4 + 16 = 21

  1. 11001100

  2. 128 + 64 + 8 + 4 = 204

\

Two’s complement:

The leftmost bit (128 in an 8-bit sequence) is called the most significant bit (MSB). In two’s complement, the MSB is negative.

When the number is positive, the MSB is 0, and when it is negative, the MSB is 1.

Negative den to two’s complement:

  1. -11

11110101

  1. -43

11010101

  1. -123

10000101

Hex to Bin:

  1. 11

00010001

  1. 2B

00101011

  1. AA

10101010

Bin to Hex:

  1. 10010011

93

  1. 11011001

D9

  1. 10101100

AC

Binary is not designed for humans to understand, hexadecimals make the values more recognisable for the human eye. This increases efficiency and reduces human error.

A value over 255 (the max an 8-bit register can store) will cause an overflow error when adding binary integers.

When shifting binary integers, the MSB is lost and the LSB value is 0 (rightmost bit)


As this is still a work in progress, feel free to view the roadmap here to check for future updates.

If you have any features you would like to suggest, or notice any issues with the website, please submit an issue on Github.

If you like the work, consider supporting us by following Madelyn’s Github or checking out Valentina’s personal website!