NumberSystems
NumberSystems
Number systems:
To express any number we can use combina�ons of ten dis�nct symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Hence this
number-system is called decimal number-system or base-ten-number-system. The symbols are known as the digits. In
this number-system, we combine more than one symbols to express numbers greater than nine. There is a patern in
which digits are combined sequen�ally. (Leading zeros on the le� does not change the value of the number.)
Suppose we are allowed to use more than ten dis�nct symbols to express numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,
D, E, and F. Here we have sixteen symbols and therefore we can express all numbers up to fi�een with a single
symbol. Sixteen onwards, we must combine two (or more) symbols together. However, the patern in which more
than one symbols are combined together is similar to that in the decimal system. This is known as the hexadecimal-
number-system or base-sixteen-number-system.
Similarly, if we are restricted to use only eight dis�nct symbols: 0, 1, 2, 3, 4, 5, 6, and 7, we will have the base-eight-
number-system or the octal-number-system.
In this way, it is possible to express any number with just two dis�nct symbols: 0, and 1. This is the binary-number-
system or base-two-number-system. Now the symbols 0, and 1 are called the bits. This is the system that all the
computers and digital electronics work on (why?).
In decimal system, the number three thousand four hundred and fi�y-six, (3456)10 can be expressed as
3456 = 3 × 103 + 4 × 102 + 5 × 101 + 6 × 100 … 1
The symbols at different places (posi�ons) have different weightage (significance).
The right-most symbol has the least weightage (significance) and it is known as the least-significant-digit.
The le�-most symbol has the highest weightage (significance) and it is known as the most-significant-digit.
Right-most Second right- Third right-most … n-th digit from
digit most digit digit the right
0 1 2
Weight/ Significance in 10 10 10 … 10𝑛𝑛−1
decimal system Ten raised to the Ten raised to the power Ten raised to the Ten raised to the power
power zero one power two (n-1)
In other number systems as well the symbols at different posi�ons have different weightage or significance.
Right-most Second right-most Third right-most … n-th symbol from
symbol symbol symbol the right
0 1 2
Weightage in 16 16 16 … 16𝑛𝑛−1
hexadecimal system Sixteen raised to the Sixteen raised to the Sixteen raised to the Sixteen raised to the
power zero power one power two power (n-1)
Weightage in octal 80 81 82 … 8𝑛𝑛−1
system Eight raised to the Eight raised to the power Eight raised to the Eight raised to the power
power zero one power two (n-1)
Weightage in binary 0 1 2 … 𝑛𝑛−1
2 2 2 2
system Two raised to the Two raised to the power Two raised to the power Two raised to the power
power zero one two (n-1)
In all the systems, the le�most symbol is most-significant, and the rightmost symbol is least-significant (weight = 1).
In general, the weight for the 𝑛𝑛-th symbol from the right in base 𝑟𝑟 system is = 𝑟𝑟 𝑛𝑛−1
Food for thought: Prove the above using the knowledge of permuta�ons and combina�ons
Conversion from other systems to the decimal system:
Example: Find the decimal equivalent of the binary number (1010)2
The decimal equivalent of (1010)2
= �1 × (23 ) + 0 × (22 ) + 1 × (21 ) + 0 × (20 )�10
= �1(8) + 0(4) + 1(2) + 0(1)�10
= (10)10
1
Here all symbols in blue have their usual meaning as in the decimal number system
Example: The decimal equivalent of (4321)8
= �4 × (83 ) + 3 × (82 ) + 2 × (81 ) + 1 × (80 )�10
= �4 × (512) + 3 × (64) + 2 × (8) + 1 × (1)�10
= (2257)10
Write the remainders from the botom to the top as: 11001
This is the binary equivalent of the decimal number (25)10
Thus (25)10 = (11001)2
Write the remainders from the botom to the top as: 4321
This is the binary equivalent of the decimal number (2257)10
Thus (2257)10 = (4321)8
Write the remainders from the botom to the top as: FACE
This is the binary equivalent of the decimal number (64206)10
Thus (64206)10 = (𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹 )16
So far, we have leant to covert decimal numbers to other systems and from any other system to the decimal system.
Hence, we can convert from any system to any other system.
There is also a direct way to convert between binary and octal systems
Example: Convert (1010011)2 into octal form
(1010011)2
= (001 010 011)2 [grouped into threes star�ng from the right, appending zeros to the le� if required.]
=( 1 2 3)8 [convert each group of three to octal form independently.]
The le�-most symbol a�er the decimal point has the highest weightage (significance) 10−1 .
The weightage/significance keeps reducing as we move towards the right.
First digit a�er Second digit a�er Third digit a�er … n-th digit a�er
the point the point the point the point
Weight/ Significance in 10 −1
10 −2
10−3 … 10−𝑛𝑛
decimal system Ten raised to the power Ten raised to the power Ten raised to the power Ten raised to the
minus one minus two minus three power −𝑛𝑛
Write the overflows from the top to the botom as: 0.1101…
This is the binary equivalent of the decimal number (0.8125)10
Thus (0.8125)10 ≈ (0.1101)2
Write the overflows from the top to the botom as: 0.10011…
(in this case, it never ends, but we must stop at some point depending on how much
precision we want)
This is the binary equivalent of the decimal number (0.6)10
Thus (0.6)10 ≈ (0.10011)2
Write the overflows from the top to the botom as: 0.64
This is the octal equivalent of the decimal number (0.8125)10
Thus (0.8125)10 ≈ (0.64)8
Ques�on: Find the highest (posi�ve) integer that can be expressed with an n-bit binary number.
Answer: 2𝑛𝑛 − 1 (Prove yourselves)
Ques�on: How many bits are required to express a posi�ve integer 𝑋𝑋?
Answer: ⌈log 2 𝑋𝑋⌉ (Prove yourselves)
Binary Arithme�c
Addi�on:
0 + 0 = 0 (Zero + Zero = Zero)
0 + 1 = 1 (Zero + One = One)
1 + 0 = 1 (One + Zero = One)
1 + 1 = 10 (One + One = Two) We say One + One sums to Zero and yield a carry of One
1 + 1 + 1 = 11 (One + One +One = Three) We say One + One +One sums to One and yield a carry of One
Mul�-bit binary addi�on can be performed on pen and paper just like decimal addi�on
Example: Add two-hundred-eighteen and two-hundred-one
two-hundred-eighteen in binary is 11011010
two-hundred-one in binary is 11001001
1 1 0 1 1 0 1 0 = two-hundred-eighteen
+ 1 1 0 0 1 0 0 1 = two-hundred-one
= four-hundred-nineteen
Subtrac�on:
0 – 0 = 0 (Zero – Zero = Zero)
1 – 0 = 1 (One – Zero = One)
1 – 1 = 1 (One – One = Zero)
0 – 1 = ? (Zero-One=?)
We borrow a 1 to the le� of the minuend and write it as 10 – 1 (two – one)
This results in a difference of 1 with a borrow of 1
0 – 1 – 1 = ?(Zero-One-One=?)
We borrow a 1 to the le� of the minuend and write it as 10 – 1–1 (two – one – one)
This results in a difference of 0 with a borrow of 1
Mul�-bit binary subtrac�on can be performed on pen and paper just like decimal subtrac�on
Example: Subtract one-hundred-six from one-hundred-forty-seven
one-hundred-forty-seven in binary is 10010011
one-hundred-six in binary is 1101010
1 0 0 1 0 0 1 1 = one-hundred-forty-seven
– 1 1 0 1 0 1 0 = one-hundred-six
= forty-one
Mul�plica�on:
0 × 0 = 0 (Zero × Zero = Zero)
0 × 1 = 0 (Zero × One = Zero)
1 × 0 = 0 (One × Zero = Zero)
1 × 1 = 1 (One × One = One)
Mul�-bit binary mul�plica�on can be found on pen and paper just like decimal mul�plica�on
Example: Mul�ply five with six
six in binary is 110
five in binary is 101
1 1 0 = six
× 1 0 1 = five
1 1 0
0 0 0
+ 1 1 0
1 1 1 1 0 = thirty
Division:
Example: Divide twenty-two with six
Twenty-two in binary is 10110
Six in binary is 110
1 1 0 1 0 1 1 0 0 1 1
0 0 0
1 0 1 1
1 1 0
1 0 1 0
1 1 0
1 0 0
Complements:
One’s complement in binary:
Given a binary number, if we replace all the zero bits with one and all the one its with zero, we get one’s complement
of the given number
Example: 1’s complement of 1010 is 0101
The remaining three bits represent the value or the magnitude of the number
In the above example the number is nega�ve (sign bit is 1). And the magnitude is 101 i.e. five. Hence the above
example represents minus five.
This way, with 4 bits, we can represent integers from minus seven to plus seven.
This way, 0 000 and 1 000 both represents zero – that’s not good.
Example:
Plus three should be represented as 0 011.
Minus two should be represented as 1 010.
Now if we want to add plus three and minus two, how should we do that – that’s to clumsy.
There is a beter way to represent nega�ve numbers which makes arithme�c very simple. This is known as 2’s
complement representa�on discussed below.
0 0 1 1 = Plus three
+ 1 1 1 0 = Minus two
1 0 0 0 1 = Plus one
Thus, signed numbers can be added just like ordinary unsigned numbers.
2’s complement representa�on of signed numbers allows to mul�ply of signed-numbers just like ordinary unsigned
numbers.
Example: Mul�ply minus two and three using 4-bit signed 2’s complement representa�on
4-bit signed 2’s complement representa�on of minus two is 1110
4-bit signed 2’s complement representa�on of three is 0011
1 1 1 0 = minus two
× 0 0 1 1 = plus three
1 1 1 0
1 1 1 0
0 0 0 0
+ 0 0 0 0
0 1 0 1 0 1 0 = minus six