PPS - Ch-1.Number System
PPS - Ch-1.Number System
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
Conversion Among Bases
• The possible conversion
Decimal Octal
Binary Hexadecimal
Binary to Decimal
Decimal Octal
Binary Hexadecimal
Technique for conversion
• Multiply each bit by 2n, where n is the “weight” of the bit
• The weight is the position of the bit, starting from 0 on
the right
• Add the results
Example
.
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
Octal to Decimal
Decimal Octal
Binary Hexadecimal
Technique for conversion
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
Decimal Octal
Binary Hexadecimal
Technique for conversion
• Multiply each bit by 16n, where n is the “weight” of the
bit
• The weight is the position of the bit, starting from 0 on
the right
• Add the results
Example
Decimal Octal
Binary Hexadecimal
Technique for conversion
• Divide by two, keep track of the remainder
• First remainder is bit 0 (LSB, leastsignificant bit)
• Etc.
Example
12510 = ?
12510 = 11111012
Octal to Binary
Decimal Octal
Binary Hexadecimal
Technique for conversion
• Convert each octal digit to a 3bit equivalent binary
representation
7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
Decimal Octal
Binary Hexadecimal
Technique for conversion
• Convert each hexadecimal digit to a 4bit equivalent
binary representation
Example
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Decimal to Octal
Decimal Octal
Binary Hexadecimal
Technique of conversion
• Divide by 8
• Keep track of the remainder
Example
123410 = ?8
8 1234
8 154 2
8 19 2
8 2 3
0 2
123410 = 23228
Decimal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Technique of conversion
• Divide by 16
• Keep track of the remainder
Example
123410 = ?16
16 1234
16 77 2
16 4 13 = D
0 4
123410 = 4D216
Binary to Octal
Decimal Octal
Binary Hexadecimal
Technique for conversion
1 3 2 7
10110101112 = 13278
Binary to Hexadecimal
Decimal Octal
Binary Hexadecimal
Technique for conversion
• Group bits in fours, starting on right
• Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
Octal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Technique for conversion
• Use binary as an intermediary
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
Hexadecimal to Octal
Decimal Octal
Binary Hexadecimal
Technique for conversion
1 7 4 1 4
1F0C16 = 174148
Binary Addition
• Two 1bit values
A B A+B
0 0 0
0 1 1
1 0 1
1 1 10
Binary Addition
• Two nbit values
– Add individual bits
– Propagate carries
– E.g.,
10101 21
+ 11001 + 25
101110 46
Multiplication
A B A×B
0 0 0
0 1 0
1 0 0
1 1 1
Example of multiplication
• Binary, two nbit values
– As with decimal values
1110
– E.g., x 1011
1110
1110
0000
1110
10011010
Binary Subtraction
Have previously looked at the subtraction operation. A quick review.
Just like subtraction in any other base
Minuend 10110
Subtrahand 10010
Difference 00100
And when a borrow is needed. Note that the borrow gives us 2 in the current bit position.
Binary Division
Binary division is also performed in the same way as we perform decimal division.
Like decimal division, we also need to follow the binary subtraction rules while
performing the binary division. The dividend involved in binary division should be
greater than the divisor. The following are the two important points, which need to
be remembered while performing the binary division.
• If the remainder obtained by the division process is greater than or equal to the
• If the remainder obtained by the division process is less than the divisor, put 0 in the
quotient and append the next most significant digit from the dividend to the
remainder
Binary Division
Perform the binary division of the decimal numbers 18 and 8.
The equivalent binary representation of the decimal number 18 is 10010.
The equivalent binary representation of the decimal number 8 is 1000.
1 0 0 0 ) 1 0 0 1 0 ( 1 0 Quotient
1 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 1 0 Remainder
Signed /Unsigned Number
Sign bit
0 0 1 1 0 0 1 0 50
Sign bit
1 0 1 1 0 0 1 0 50
Signed/Unsigned Numbers
It is very easy to
represent and
Advantages of understand
the signed positive as well
magnitude as negative
representation: numbers using
this
representation.
Represent equal
The binary number of
multiplication and positive and
the binary division negative
of the signed quantities that
binary numbers makes it a very
can be easily symmetrical
performed. method of
representation.
Signed/Unsigned Numbers
1 2 3
Disadvantages of the signed It is not an easy task to It provides two different
magnitude representation: perform the binary addition representations of zero, one
and the binary subtraction for plus zero and another for
using this representation. negative zero but actually they
are the same values. This
could lead to some confusion
while performing various
arithmetic operations.
Complements of Binary Numbers
The complement system can also be used to represent the signed binary numbers
apart from the signedmagnitude representation method.
In the complement system, the positive integers are represented in a similar manner as
they are represented in the signedmagnitude representation. The following are the two
most popular complement methods used in the computer system:
One’s complement
Two’s complement
One’s Complement
One’s complement method can be used to represent
negative binary numbers.
Sign bit
1 1 1 1 0 0 0 0 15
One’s Complement
Integers One’s complement representation
-7 1000
-6 1001 The one’s complement method
-5 1010
-4 1011
of representing signed numbers
-3 1100 also has two different
-2 1101
-1 1110
representations for the number,
-0 1111 zero.
+0 0000
+1 0001
+2 0010
+3 0011
+4 0100
+5 0101
+6 0110
+7 0111
One’s Complement
The two’s complement method also uses the left most bit as the sign bit to indicate
the sign of the number.
Sign bit
1 1 1 1 0 0 0 1 15
Two’s Complement
Integers Two’s complement representation
-7 1001
-6 1010
-5 1011
-4 1100
-3 1101
-2 1110
-1 1111
-0 0000
+0 0000
+1 0001
+2 0010
+3 0011
+4 0100
+5 0101
+6 0110
+7 0111
Two’s Complement
Now, change all the
zeros to ones and all
The equivalent binary the ones to zeros in
representation of 33 in order to obtain the
a byte is 00100001. one’s complement
representation:
11011110.
• Binary to decimal