">
Skip to Main Content or Page Contents
This tutorial is going to assist you with the different numbering systems that are used in programming. Programmers will need to be familiar with most of them.
You are already familiar with our every day denary numbering system based on the unit 10. Computers only understand the binary number system based on the unit 2 denary. Programming often uses the hexadecimal system base on a unit of 16 denary. For example HTML uses hexadecimal numbering in the color attribute, e.g. color="FF00FF". Another less common system is octal based on 8 denary.
You should know how to convert between the different systems. The windows calculator (in scientific mode) can be used for conversions. College and University students may find that calculators are not allowed in the exam, therefore manual conversion calculations must be made. This should be practiced to speed up the process, the calculator only used to check your manual conversion.
Our ASCII code page is useful for a quick conversions up to 127 denary.
A binary digit is called a bit. Usually expressed as 0 and 1 the
two numbers of the binary numbering system.
A bit is the smallest unit of information a computer can use. A 16 bit computer would
process a series of 16 bits,such as
0100111101011000 in one go, repeating the process thousands or millions of times per
second.
Reading a series of bits is very difficult and to make this process easier they are
often displayed in groups of 4 bits
0100 1111 0101 1000
This grouping is quite interesting in that a group of 4 bits can be replaced by a single
hexadecimal digit
Two groups of 4 bits, i.e. 8 bits ( a byte) can be replaced by 2 hexadecimal digits,
and 4 hexadecimal digits are required to replace all 16 bits.
Binary | ||||
Hexadecimal |
A group of 8 bits are in a byte. With 8 bits ( binary digits ), there
exists 256 possible denary combinations.
If you remember that 1 byte can store one alphabetical letter, single digit,
or a single character/symbol, such as #.
Large numbers of bytes can be expressed by kilobytes, megabytes etc
1 byte of memory can normally hold one of the following:
See the ASCII codes page which shows how the first 127 characters of 256 characters are used
The value of a kilobyte is 1024. Worked out as 2^10. Normally Kilo refers to 1000 but in computing kilobyte is 1024.
Likewise, 1024Kb is referred to as a "Megabyte". Normally a Mega refers to a million. In computing 1 Mega byte is 1,048,576 bytes. Worked out as 220, or 1024*1024.
A megabyte can store roughly 4 books of 200 pages
A Gigabyte is 1,073,741,824 (230) bytes. 1,024 Megabytes, or 1,048,576 Kilobytes.
A gigabyte can store almost 4500 books of 200 pages
You could store 1 but not 2 650MB CDs
A Terabyte is 1,099,511,627,776 (240) bytes, 1,024 Gigabytes, or 1,048,576 Megabytes.
250 bytes
260 bytes bytes
In every day life we Usually use the denary number system which has a base of 10.
But we also use other number systems, think of time (base 60, and base 10 within
it), imperial distance yards and feet (base 3), there are many others, dates probably being the hardest number system to do calculations with.
In the denary binary octal hexadecimal systems, the value of any digit in a number
depends on its position within that number. I.e. which column it is in.
To understand this we will examine the Denary system in more detail. Because you are so used to the denary system and because it is very easy to multiply by 10, 100, or a 1000 etc you calculate the number in your head. Lets use the number 256 as an example. The calculation that is automatically done is the following
The most important calculation to do is to work out the positional values for that system. The positional value is based on the powers of the number systems base value
Power of the base | 104 |
103 |
102 |
101 |
100 |
Calculation | 10x10x10x10 |
10x10x10 |
10x10 |
The value of the base number |
Any number to the power 0 is always 1 |
= Position value | 10,000 |
1000 |
100 |
10 |
1 |
Write down the Positional values for the number system you are using so for Denary we would write
Position value | 10,000 |
1000 |
100 |
10 |
1 |
Underneath the correct positional value write in your number
Position value | 10,000 |
1000 |
100 |
10 |
1 |
Enter Number | 2 |
5 |
6 |
The calculation that is done
Position value | 10,000 |
1000 |
100 |
10 |
1 |
Enter Number | 2 |
5 |
6 |
||
Required Calculation | 100x2 |
10x5 |
1x6 |
||
This equals | 200 |
50 |
6 |
Add the 3 results 200 + 50 + 6
200 |
50 |
6 |
____ |
256 |
You can convert a number in any number system to a denary number using this calculation. Ensure you use the positional values for the number system you are using
The decimal system name should not be used because of confusion that this could be thought as introducing the decimal point and money systems
Uses numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, that's 10 numbers. Hence base
10. Radix is another name for base 10.
Adding 1 to 9 we must introduce an additional column to the left i.e. 10
Power of the base | 104 |
103 |
102 |
101 |
100 |
Position value | 10,000 |
1000 |
100 |
10 |
1 |
A byte of memory can store a number in the range 0 to 255 Denary.
A series of eight bits strung together makes a byte, much as 12 makes a dozen. With
8 bits, or 8 binary digits, there exist 2^8=256 possible combinations
Uses numbers 0, 1,, that's 2 numbers. Hence base 2.
Binary numbering is the number system that is used by computers.
Note: The positional value doubles as you go to the next positional on the left
Power of the base | 24 |
23 |
22 |
21 |
20 |
Positional value | 16 |
8 |
4 |
2 |
1 |
A binary digit is called a bit. There are two possible states in a bit, Usually expressed as 0 and 1, the two numbers used in the binary number system.
But the bit could represent on / off of an electrical circuit, yes / no, true / false,
-1 / 0, -1 / +1, zero / non zero, or similar 2 state binary wording.
A byte of memory can store a number in the range 00000000 to 11111111 binary.
Numbers are often displayed in groups of 4, as follows, to make them easier to read. 0000 0000 to 1111 1111 binary.
Convert 1011 binary to denary
Positional value | 16 |
8 |
4 |
2 |
1 |
Enter Number | 1 |
0 |
1 |
1 |
|
Required Calculation | 8x1 |
4x0 |
2x1 |
1x1 |
|
This equals | 8 |
0 |
2 |
1 |
Add the 3 results 8 + 0 + 2 + 1
8 |
0 |
2 |
1 |
____ |
11 |
Therefore 1011(One Zero One One) binary = 11 (Eleven) Denary
Power of the base | 164 |
163 |
162 |
161 |
160 |
Positional value | 65536 |
4,096 |
256 |
16 |
1 |
A byte of memory can store a number in the range 00 to FF Hex Hexadecimal numbers are often displayed in groups of 2, to make them easier to read. E.g.
10 AF 3C 9F
A single hexadecimal number requires 4 units of binary numbers. This makes it reasonably easy to convert between these two numbering systems. E.g.
1 = 0001
9 = 0101
A = 1010
Power of the base | 84 |
83 |
82 |
81 |
80 |
Positional value | 4096 |
512 |
64 |
8 |
1 |
The Binary system
These states are usually represented by either the number 0 or 1 of the binary number system.
C Tutorial 4. Branch & Loop Introduction
C Tutorial 5. Branch & Loop Code
This site is hosted on Hostgator