Skip to content
Learnearn.uk » IB Computer Science » Number Representation in Binary

Number Representation in Binary

Positive Integers

Positive Integers (positive whole numbers)

Converting denary to Binary is simple. As binary numbers operate on a base 2 number system (unlike denary which is based 10) each binary digit is worth double that to the right.

Example 1 – the number 9

Here the number 9 can be be represented using the binary

8 4 2 1
1 0 0 1

Note how the numbers start from the right hard side and double in value to the left, so the left most binary digits are worth more.

Example 2 – the number 235

To represent larger numbers more bits are required. In order to represent the number 235, 8 bits are required.

128 64 32 16 8 4 2 1
1 1 1 0 1 0 1 1

Note

For the International Baccalaureate you will need to be able to convert between binary numbers from 0 to 255.

Negative Integers

Negative Integer Representation using Two’s Complement

The simple binary number representation is great, but it is limited to positive whole numbers. In order to represent negative numbers we can use on number of different systems including sign and magnitude, one’s compliment & two’s compliment. The most efficient system is two’s compliment.

Watch this video to see how two’s complement works:

Non whole-numbers

Real numbers (Non-whole numbers)

Real/floating point numbers such as 13.75 are represented in binary using a mantissa and exponent system.

Note

You will not be required to calculate floating point numbers, you just need to be aware that this is how floating point numbers are represented and the limitations of the system (i.e. floating point rounding errors)

Practice

Binary Number Conversion Practice Game

Improve you binary number conversion skill using this binary game

Resources