Sat. Jan 21st, 2023

Use and interpretation of number systems

All computer data is binary. That is, any individual piece of data can only ever be one of two values: 0 or 1.

By combining multiple values together, more meaningful information can be stored, although it is always the case that you must know what type of information you are using: different types of data will require different interpretations of the 0s and 1s.

Units of digital data

This should be common knowledge already, but:

UnitSize
bitThe smallest unit; a single 0 or 1
nibbleFour bits; e.g. 0100
byte8 bits; can store a value of 0-255 or -127 to 128
kilobyte (kb)1024 bytes
megabyte (MB)1024kb
gigabyte (GB)1024MB
terabyte (TB)1024GB
Petabyte (PB)1024TB

Binary

Binary is a number system. Its name is formed in the same manner as our standard number system – which is base 10, denary. Computers don’t work with multiples of ten, they operate in multiples of 2 (there are only two ‘digits’ which are 0 and 1).

Binary refers to a number system which contains only two different values.

In denary, we are used to this, and are taught to interpret numbers this way:

10,000,000s1,000,000s100,000s10,000s1000s100s10s1s
42137

That is, 4 lots of 10,000 added to 2 lots of 1000, 1 lot of 100, 3 lots of 10 and 7 units.

As there are ten different digits, (0 – 9), each column can represent ten different values. That means that each column moving from right to left is worth ten times more.

In binary, it appears like this:

1286432168421
10011101

There are only two possible values for each column (0 or 1), and therefore, the columns increase by a factor of 2 as you move from right to left.

Again, it should be simple to calculate that the above number is:

1*128 + 1*16 + 1*8 + 1*4 + 1*1 = 157.

Binary coded decimal

As seen above, numbers can be represented in binary.

Binary coded decimal (BCD) is an alternative scheme, and works slightly differently.

Each of the ten digits is assigned a 4-bit binary code:

DigitBCD
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001

Now, in representing denary values, each digit is replaced with the BCD equivalent:

47 would become 0100 0111

This is different to what would be obtained by converting 47 into binary (00101111).

BCD is easier to translate between denary and binary, for a human. On the other hand, it is less efficient as with 8 bits, it is only possible to represent 100 values (0 to 99), whereas in unsigned integer binary, 8 bits would be able to represent any value from 0 to 255.

Although BCD uses 4 bits per digit, it is not the same as hexadecimal – whereas in hexadecimal values up to 15 can be encoded using four bits, in BCD only values up to and including 9 are encoded.

One example of the use of BCD is in the display driver for a numeric segment display: