Number Systems
Number Systems
The first chapter of the 11th-grade computer science syllabus is number systems. This
chapter covers the use of numbers in computer hardware and hardware design.
Number Types
Chapter 1 Overview
You'll study these four number systems, including how to convert numbers from one system
to another.
Operations
Addition and subtraction operations for numbers in different bases will be covered in the
next part.
Non-positional number systems were used in old times when there were no counting
methods.
• One: |
• Two: ||
• Three: |||
• Four: ||||
• Five: ||||/
• Six: ||||/|
The major drawback of non-positional number systems is that we couldn't count bigger
numbers using them.
Positional number systems are the modern number systems that we use in daily life. Non-
positional number systems had drawbacks, such as the inability to count large numbers
effectively.
In positional number systems, the position of a symbol (number) determines its value.
Decimal Numbers
We use decimal numbers in daily life. A decimal number is a positional number system
where each place has a value.
In positional number systems, the value of a symbol changes based on its position. For
instance, 1 in the ones place means one, but 1 in the tens place means ten, and 1 in the
hundreds place means one hundred.
• Binary
• Octal
• Decimal
• Hexadecimal
Binary Numbers
Binary means two. In the binary system, only two symbols are used: 0 and 1.
Octal Numbers
Oct means eight. In the octal number system, eight symbols are used: 0, 1, 2, 3, 4, 5,
6, and 7.
Decimal Numbers
Deci means ten. In the decimal number system, ten symbols are used: 0, 1, 2, 3, 4, 5, 6, 7,
8, and 9.
Hexadecimal Numbers
Hexa means six, and deci means ten. Therefore, hexadecimal means 16. In the hexadecimal
number system, 16 symbols are used.
Conversions
Understanding number systems is crucial for converting values between them. Conversions
are a key skill to learn, as you likely won't be asked to simply define a number system.
The binary number system is particularly important. It isn't used in our daily lives, but it's
fundamental to how computers store and process information.
Base-2 System
The binary number system has a base of 2, indicated by the "bi" in "binary."
Computer's Language
States
• 0 (off)
• 1 (on)
Since computers run on electricity, these states correspond to the presence (1) or absence
(0) of voltage or a signal.
Pulses
Signals are sent as pulses between circuits, and these pulses are either on (1) or off (0).
Even though computers use binary, humans design computers. Therefore, understanding
binary is crucial for designing and building computer hardware.
What is Binary?
Binary Numbers
Let's look at how numbers are represented in binary using the following table:
Decimal Binary
0 0
1 1
2 10
3 11
4 100
Binary Number Conversion
When you reach a limit (like 1), you carry over to the next digit on the left, similar to how
you increment in decimal numbers.
• 5: 1001
• 6: 1010
• 7: 1011
• 8: 1000
• 9: 1001
• 10: 1010
• 11: 1011
• 12: 1100
• 13: 1101
• 14: 1110
• 15: 1111
• Actual conversion
• Shortcut method
Shortcut Method
The shortcut method involves remembering the sequence 8 4 2 1. These numbers represent
place values.
For example, to make 7, you add 4 + 2 + 1. So, the binary representation is 0111.
To determine where to put ones, think about it like this: "Put ones in places that add up to
our target number."
Therefore:
• 16's place: 1
• 8's place: 1
• 4's place: 0
• 2's place: 1
• 1's place: 0
Shortcut Method
The shortcut method is convenient for smaller numbers but can become challenging with
larger numbers.
The proper method for converting decimal to binary is the "divide by two" method. This is
the method that should be used in exams.
1. Divide 28 by 2:
• 28 ÷ 2 = 14, remainder 0
2. Divide 14 by 2:
• 14 ÷ 2 = 7, remainder 0
3. Divide 7 by 2:
4. Divide 3 by 2:
5. Last remainder: 1
Therefore, 2810=1110022810=111002.
Practice Question
Solution
1. 68 ÷ 2 = 34, remainder 0
2. 34 ÷ 2 = 17, remainder 0
3. 17 ÷ 2 = 8, remainder 1
4. 8 ÷ 2 = 4, remainder 0
5. 4 ÷ 2 = 2, remainder 0
6. 2 ÷ 2 = 1, remainder 0
7. Last remainder: 1
Therefore, 6810=100010026810=10001002.
Now, let's dive into how to convert from binary to decimal. We're doing this conversion first
because everyone is familiar with decimal numbers.
Understanding Positional Number Systems
Remember, binary, decimal, octal, and hexadecimal are all positional number systems. This
means that each digit's position has a specific value.
In decimal, we have places like ones, tens, hundreds, thousands, etc. In binary, the place
values are powers of 2:
• And so on...
Conversion Process
For example, let's convert the binary number 100 (base 2) to decimal:
1∗22+0∗21+0∗20=1∗4+0+0=41∗22+0∗21+0∗20=1∗4+0+0=4
Key Insight: You only need to consider the positions where you have a 1 because
the 0 positions will always result in zero.
Example
1∗23+0∗22+1∗21+1∗20=1∗8+0+1∗2+1∗1=8+0+2+1=111∗23+0∗22+1∗21+1∗20=1∗8+0+1∗2+1
∗1=8+0+2+1=11
Exam Tips
This notation indicates that you need to convert the binary number 1011 to its decimal
equivalent.
Example
To solve this, identify the positions where you have a 1 and calculate their place values:
1+2+16+128=1471+2+16+128=147
To convert a binary number to a decimal number, multiply each one by its place value and
add them up. The place values are powers of 2, starting from 2020 on the right. If a place
has a zero, its value is not added.
1∗28+1∗24+1∗21+1∗201∗28+1∗24+1∗21+1∗20
=256+16+2+1=275=256+16+2+1=275
Octal Numbers
Definition
Decimal Octal
0 0
1 1
2 2
3 3
4 4
Decimal Octal
5 5
6 6
7 7
1∗26+1∗22+1∗201∗26+1∗22+1∗20 =64+4+1=69=64+4+1=69
Octal Numbers
Octal numbers use eight symbols, ranging from 0 to 7. Converting decimal to octal is
straightforward as long as we stay within these symbols.
The problem arises when we reach 8 in decimal, because we don't have an equivalent single
symbol in octal. In octal, we "reset" to 0 and add a 1 to the left, similar to how we handle
binary numbers.
• Decimal 11 is 13 in octal.
• Decimal 12 is 14 in octal.
• Decimal 13 is 15 in octal.
• Decimal 14 is 16 in octal.
• Decimal 15 is 17 in octal.
While octal numbers might not be as commonly used as other number systems, they do find
applications in certain computers.
Conversions
The primary focus is on conversions, as exam questions will likely revolve around them.
Octal to Binary
Decimal/Octal Binary
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
• Binary to Octal
• Octal to Binary
• Octal to Decimal
• Decimal to Octal
Here's how to convert an octal number (base 8) to a binary number (base 2).
Conversion Method
The trick is to represent each octal digit with its 3-bit binary equivalent.
• 1 becomes 001
• 7 becomes 111
• 3 becomes 011
Therefore, 1738=00111101121738=0011110112.
If you're having trouble converting to binary, use the "8421" method. This method relies on
the following place values:
8 4 2 1
To convert a decimal number to binary, find which combination of these values sums to the
decimal number. Put a 1 in the corresponding columns, and 0 in the others.
To convert from octal to binary, each octal digit is represented by its 3-bit binary equivalent.
• 2 = 010
• 7 = 111
• 3 = 011
• 4 = 100
So, the octal number 2734 is equivalent to the binary number 010111011100.
Converting from binary to octal is the reverse process of converting from octal to binary.
Just reverse of above: Make groups of three. Write octal for each group.
1. Group the binary digits into sets of three, starting from the right.
2. If the number of binary digits is not a multiple of three, add leading zeros to the
leftmost group to make it a group of three.
• 001 = 1
• 101 = 5
• 011 = 3
Therefore, the binary number 1101011 is equivalent to the octal number 153.
Remember:
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
1. Group the binary digits from the right: 10 011 001 100
• 010 = 2
• 011 = 3
• 001 = 1
• 100 = 4
Therefore, the binary number 10011001100 is equivalent to the octal number 2314.
To convert from binary to octal, group the binary digits into sets of three starting from the
right side. Then, convert each group of three binary digits into its octal equivalent.
100110110
1. Group the digits into sets of three: 100 110 110
This conversion involves multiplying each digit by its place value and then adding all the
results together. The place values in octal are powers of 8.
Place Value: In an octal number, the place values are powers of 8, starting from 8^0 on the
rightmost digit.
Calculation:
1∗81+2∗80=1∗8+2∗1=8+2=101∗81+2∗80=1∗8+2∗1=8+2=10
So, 128=1010128=1010
To convert the octal number 4571 into decimal, we need to multiply each digit by its
corresponding power of 8 and then add the results:
1. Place values:
• 1 is at 8080
• 7 is at 8181
• 5 is at 8282
• 4 is at 8383
Therefore, 45718=24251045718=242510
Octal to Decimal Conversion
The rule for converting any base number to decimal is similar: take the number at a place
and multiply it by its place value. For octal, place values are powers of 8. For binary, place
values are powers of 2.
1. Divide 2425 by 8:
2. Divide 303 by 8:
3. Divide 37 by 8:
As a check, recall when 4571 (octal) was converted to decimal, the result was 2425. If a
conversion is done one way, doing the reverse should yield the original number.
Number Systems
• Binary number system and its conversions (Binary to Decimal, Decimal to Binary).
• Octal number system and its conversions (Octal to Binary, Binary to Octal, Octal to
Decimal, Decimal to Octal).
• "Hexa" means 6.
• "Decimal" means 10.
The hexadecimal number system is a base-16 system, meaning it uses 16 symbols. These
symbols range from 0 to 9 and A to F, where A represents 10, B represents 11, C represents
12, D represents 13, E represents 14, and F represents 15.
• A = 10
• B = 11
• C = 12
• D = 13
• E = 14
• F = 15
This system is commonly used in color coding for computers, websites, and other digital
interfaces.
Decimal Hexadecimal
0 0
1 1
2 2
3 3
4 4
5 5
6 6
Decimal Hexadecimal
7 7
8 8
9 9
10 A
11 B
12 C
13 D
14 E
15 F
When you reach the limit of symbols (F), you reset to 0 and add 1 to the next digit. So, 16 in
decimal is represented as 10 in hexadecimal, and 17 is 11. Note that 10 in hexadecimal is
NOT the same as 10 in decimal.
Practical Use
The practical use for hexadecimal numbers is color coding, such as those used in websites. In
this case, hexadecimal is used to represent different colors.
Hexadecimal Conversions
To convert a hexadecimal number to binary, write the four-bit binary equivalent for each
hexadecimal digit.
• 1 = 0001
• A = 1010
Therefore, 1A (hexadecimal) = 0001 1010 (binary)
Hexadecimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A (10) 1010
Hexadecimal Binary
B (11) 1011
C (12) 1100
D (13) 1101
E (14) 1110
F (15) 1111
• 9 = 1001
• F = 1111
• 1 = 0001
• A = 1010
1. Split the binary number into groups of four from the right side:
• 1001 = 9
• 1001 = 9
• 1010 = A
3. The hexadecimal equivalent is 99A.
For example, to convert the binary number 1010 0001 1111 1001 to hexadecimal:
• 0001 translates to 1
Example
• 1 becomes 0001
4. Group the binary digits into sets of three for octal conversion: 000 110 10
The importance of grouping binary digits into sets of three is due to the fact that each digit in
an octal number represents a power of 8, and each power of 8 can be represented by three
binary digits.
• 110 becomes 3
• 010 becomes 2
Practice Problem
• 2 is 0010
• F (15) is 1111
• 9 is 1001
• 001 is 1
• 011 is 3
• 111 is 7
• 001 is 1
1. Convert the octal number to binary. To convert to binary, represent each octal digit
with its three-bit binary equivalent.
Essentially, the process involves converting from octal to binary, and then
from binary to hexadecimal.
Example:
1. Convert to binary:
• 1 becomes 001
• 3 becomes 011
• 7 becomes 111
• 1 becomes 001
• 1010 = 9
• 1111 = F
• 0010 = 2
Therefore, (1371)8=(2F9)16(1371)8=(2F9)16.
To convert from decimal to hexadecimal, repeatedly divide the decimal number by 16.
Example:
1. Divide 25 by 16:
Since the quotient (1) is less than 16, we stop here. 2. Write the remainders in reverse order:
3. Continue dividing the quotient by 16 until the quotient is less than 16.
4. The remainders, read from bottom to top, give the hexadecimal equivalent.
This conversion involves multiplying each digit by its place value. The rule is the same as
converting any base number to decimal.
To convert from any base to decimal, multiply each digit by its place value.
Example 1
Example 2
4. f represents 15 in decimal.
So, 2⋅162+6⋅161+15⋅160=2⋅256+6⋅16+15⋅1=512+96+15=6232⋅162+6⋅161+15⋅160=2⋅2
56+6⋅16+15⋅1=512+96+15=623 Therefore, 26f (hexadecimal) is equal to 623
(decimal).
Remember:
• A = 10
• B = 11
• C = 12
• D = 13
• E = 14
• F = 15
Here's a quick recap of how to convert between decimal and other bases: