We have learnt that because computers utilise transistors, computers use a binary base system of bits to represent data.

So whether or not you are representing strings, decimal numbers, integers, characters, booleans or colours they are all represented in binary in a computer.

4 bits make a nibble, 8 bits a byte and 8, 16 or 24 bits usually make a Word,

which is the minimum size that a processor can process in one go.


There are 3 important base systems for IB Computer Science:


Decimal (base 10) also known as denary (Latin:den). We use this system all around the world. The 10 Arabic originated digits from 0 to 9

was probably a given since we have 10 fingers and toes!


= (100 *3) + (10*5) + (1*0) =350



Binary (base 2) is used as machine code. Each key on a keyboard for example is encoded to give a binary number to represent that character.

To standardardise keyboards the Americans invented the ASCII system which set aside 7 bits to represent characters.

ASCII Extended ( 8 bits) solved the problem for languages that use or are based on the Latin alphabet..é or umlauts for example. 256 characters could be represented. What about the others needing a completely different alphabet? Greek? Russian? Chinese and the likes?

We would have needed an entirely new character set... that's the rational behind Unicode. Unicode is a subset of ASCII but uses up to 32 binary bits .


Binary (base 2)


101 = 4 + 1 (ignore where there is a zero) = 5


You may be asked how many megabytes in a gigabyte for example. The key to this is to remember that K refers to 1000's, with 3 zeros. You know this, as 1 Km is a 1000 metres for example.

Similarly M means millions with 6 zeros. Gigabytes refers to billions, represented with 9 zeros. and terrabytes 12 zeroes

So how many Megabytes are in 4.14 Gb? We need to move right 3 (9-6) positions from the decimal point so 4140Mb = 4.14Gb


Hexadecimal (base 16)

Hexadecimal (base 16). Hex means 6 and decimal =10 so 6 and 10 gives us the base 16. Why is hex so useful? Well it is much easier to write 6D than 01101101. There is less chance of making an error

Hex is also used to identify colours using the RGB colour system in html and grahics editors like Photoshop. Two hex characters will have 8 bits available which
would give 2^8 or 256 colours

Hexadecimal (base 16)

There are 16 hex digits 0 1 2 3 4 5 6 7 8 9 A B C D E F

Each hex digit can be represented by 4 binary bits


5A in Hex = 16*5 + 1*10 = 90


colours in hex





hex convert

To convert this to denary it would be (16*6) + (1*13) = 109

(6D)16 = (109)10


To convert (109)10 to hex you could convert to binary first


Converting Decimal to Hex

E.g. 894

894/16 = 29 R15 (F)

29/16 =1 R13 (D)

1/16 = 0 R 1

894 = 1DF


Can you work the above out?