The Binary Number System

In the denary or decimal number system (sometimes called the Hindu-Arabic number system) numbers are formed from powers of 10. Working from the right we have units, tens, hundreds, thousands, etc., or 10^0, 10^1, 10^2, 10^3, etc.

10^0=1, 10^1=10, 10^2=100, 10^3=1,000, etc.

In base 10 we multiply each column by the actual number there, so for example:

2,345 = 2 * 10^3 + 3 * 10^2 + 4 * 10^1 + 5 * 10^0

= 2,000 + 300 + 40 + 5 = 2,345

In binary we proceed in the same way but we use powers of 2. In binary (base 2) there are just 2 symbols, 0 and 1. This is useful in computing because transistors have 2 states, off and on, so there is a neat correspondence of 0=off and 1=on. A great deal can be done with just these two digits and they have formed the basis of electronic digital computing.

Thus the right hand column of a whole number is 2^0, that is zero or 1 (2^0=1, in fact, by convention, any number ^ 0 = 1, 3^0=1, 4^0=1, etc.) Its possible values are 1 or 0 so it can be 0 * 2^0 = 0, or 1 * 2^0 = 1.

The second column from the right is 2^1 = 2. Its possible values are 1 or 0 so it can be:

0 * 2^1 = 0 or 1 * 2^1 = 2.

Thus for 8 bits we have:

Powers of 2: 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
Denary value if binary‘1’: 128 64 32 16 8 4 2 1
Largest value: 1 1 1 1 1 1 1 1

The largest value in 8 bits is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. 256 = 2^8 so the largest value is 2^8-1: 256-1=255.

Character Codes and Simple Encryption

The ASCII and Unicode values for common codes are as follows:

0 (zero) : 48

Subsequent ASCII codes are 49, 50, 51, 52, 53, 54, 55, 56, 57

A : 65

Subsequent letter codes are 66, 67, etc. Lower case 'a' is 97, others follow on in sequence.

Translate a short message into character codes and pass it to a neighbour to decode.

Your message is encoded but not encrypted. What is the difference between these two words? Can you use a simple strategy to encrypt your message? Compose a different message in code values, encrypt it with a simple method and then pass it to your neighbour to decode. How will they set about decoding it? Hints here.

Useful program here. You can use this to encrypt your emails!

Cryptography is an enormous and complicated field and a significant branch of mathematics.

Hexadecimal

Binary is rather cumbersome for humans to read and write so a shorthand has been developed called hexadecimal. Binary has 2 digits, denary has 10 digits and hexadecimal has 16 digits. The characters used in hexadecimal are: 0-9 + A, B, C, D, E, F. These represent the 4-bit patterns from 0-15:

Hexadecimal value Binary value
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A (10) 1010
B (11) 1011
C (12) 1100
D (13) 1101
E (14) 1110
F (15) 1111

Thus an 8-bit number can be represented by two hexadecimal digits and a 16-bit number can be represented by 4 hexadecimal digits. The link between binary and hexadecimal is more obvious than that between binary and denary. If you want to know the denary value you will still have to convert from binary or hexadecimal - the 16-times table will come in handy here!

Examples:

AB = 1010 1011 (=10 x 16 + 11 = 171 in denary)

4F = 0100 1111 (=4 x 16 + 15 = 79 in denary)

Click Back to return