# 6 Representing numbers in binary

Now looking at the encoding for numerals in Table 2, we can see how the characters 0–9 are represented in UTF-8.

## Table 2 ASCII table for numerals

Binary code | Character
0011 0000 | 0
0011 0001 | 1
0011 0010 | 2
0011 0011 | 3
0011 0100 | 4
0011 0101 | 5
0011 0110 | 6
0011 0111 | 7
0011 1000 | 8
0011 1001 | 9

Note, this is the character representation of the number to display that number on a screen or to print in a document. It is not the actual representation that a processor will use when preforming numerical calculations!

Consider the number ‘11’. To print this number we use two characters, a ‘1’ followed by another ‘1’. However, this is a very inefficient way for a processor to handle numbers in a calculation. Instead, the number eleven can be simply encoded in a byte as 00001011. That is one byte, not two, and in a form that instructions such as add and subtract can be directly applied to the bits for efficient calculations. There are other special ways to encode numbers for processing. They are beyond the scope of this course.

Modern computer programming languages such as Python handle the conversion between the two representations of a number automatically. However, in many languages it is for the programmer to declare in the program whether a number is to be used say for printing on a report, or for calculating the values to be printed.

The logic of the program informs the processor how to handle each byte, whether it represents a character or a number, or even another data format altogether as you shall see in the next section.

OpenLearn - An introduction to computers and computer systems
Except for third party materials and otherwise, this content is made available under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Licence, full copyright detail can be found in the acknowledgements section. Please see full copyright statement for details.