Professional Documents
Culture Documents
• Eg: 1011 = 1* 23 + 0 * 22 + 1* 21 + 1 *2
= 8 + 0 + 2 +1
= 11
Number System
Decimal numbers
◦ Decimal digits: (0,1,2,3,4,5,6,7,8,9)
7392 =7000+300+90+2
=7*1000+3*100+9*10+2
=7*103 + 3*102 +9 *101 +2 *100
◦ 97654.35 = 9x104 + 7x103 + 6x102 + 5x101 + 4x100 + 3x10-1 + 5x10-2
◦ Formal notation -> (97654.35)10
◦ Here 10 is the base or radix
Number System
Octal numbers
Octal digits: (0,1,2,3,4,5,6,7)
◦ (4536)8 = 4x83 + 5x82 + 3x81 + 6x80 = (1362)10
◦ (465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2
Octal numbers don’t use digits 8 or 9
Hexadecimal numbers
Hexadecimal digits: (0 to 9, A to F)
(D63FA)16 =13*164 + 6*163 + 3*162 +15*161 +10*160
= (877562)10
Number System
Binary numbers
Binary digits (bits): 0 and 1
◦ (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10
◦ (110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2 = (6.5)10
Groups of eight bits are called a byte
◦ (11001001) 2
Groups of four bits are called a nibble.
◦ (1101) 2
Number System
Why Use Binary Numbers?
° Easy to represent 0 and 1 using
electrical values.
° Possible to tolerate noise.
° Easy to transmit data
° Easy to build binary circuits.
1 AND Gate
0
0
Number System
Conversion Between Number Bases
Group 3 bits
Octal(base 8)
Group 4 bits
Hexadecimal
(base16)
Number System
Conversion
Decimal :
Binary - divide by 2
Octal - divide by 8
Hexadecimal - divide by 16
Binary
Decimal - Multiply by 2
Octal - combine 3 bits
Hexadecimal - combine 4bits
Octal
Binary – represent each element in 3 bit
Decimal - Multiply by 8
Hexadecimal – convert to binary then group by 4 bit
Hexadecimal
Binary – represent each element in 4 bits
Decimal – Multiply by 16
Octal - convert to binary then group by 3 bit
Number System
2 20
8 48 16 1256
2 10 0
8 6 0 16 78 8
2 5 0
16 4 1
2 2 1 (48)10= (60)8 4
2 1 0
(1256)10= (4E8)16
(20)10= (10100)2
Number System
(10100)2 = (20)10
1 0 1 0 0 1 0 1 1
24 23 22 21 20 2-1 2-2 2-3 2-4
20 0.6875
(10100.1011)2 = (20.6875)10
Number System
Binary: Octal
(110000.1011)2 = 110 000. 101 100
= 6 0 . 5 4
(110000.1011)2 = (60.54)8
Binary: Hexadecimal
(010011101000)2 =(4E8.B)16
Number System
Octal: Decimal - Octal : Hexadecimal -
Octal : Binary -
Multiply by 8 convert to binary then
each element in 3 bit
group by 4 bit
6 110 6 0
81 80 (60)8= (110000)2
0 000 = 11 0000
6*8 0*8 = 3 0
48 0
(60)8= (30)16
(60)8= (110000)2 48
(60)8= (48)10
Number System
Octal: Decimal
Octal : Binary -
6 0 4 0 6 5
6 110 81 80 8-1 8-2 8-3 8-4
0 000
5 101 6*8 0*8 4/8 0/64 6/512 5/4096
4 100 48 0 0.5 0 0.011718 0.00122
48 0.5129
(60.54)8= (110000.101100)2
(60.4065)8= (48.5129)10
Octal : Hexadecimal
(60.4065)8= (110000.100000110101)2
= 11 0000.1000 0110 1010
= 3 0 . 8 6 A
(60.4065)8= (30.86A)16
Number System
Hexadecimal : Binary
Hexadecimal : Decimal Hexadecimal : Octal - -
- – represent each
- Multiply by 16 convert to binary then
element in 4 bits
group by 3 bit
4 0100
(4E8)16 =
E 1110 4 E 8
(010 011 101 000)2
8 1000 162 161 160 = 2 3 5 0
(4E8)16 =(1256)10
Number System
Hexadecimal : Decimal
Hexadecimal : Binary
4 0100 4 E 8 B
E 1110 162 161 160 16-1
8 1000 4*256 14*16 8*1 11/16
B 1011 1024 224 8 0.687
5
(4E8.B)16 =(1256.6875)10
(4E8.B)16 = (2350.54)8
Number System
n 2n n 2n
0 20=1 8 28=256
1 21=2
9 29=512
2 22=4
10 210=1024
3 23=8
11 211=2048
4 24=16
12 212=4096
5 25=32
20 220=1M Mega
6 26=64
30 230=1G Giga
7 27=128 Tera
40 240=1T
Number System
Binary Addition
Binary addition is very simple.
This is best shown in an example of adding two binary numbers…
1 1 1 1 1
1 carries
1
1 1 1 0 1 Augend
+ 1 0 1 1 1 Addend
---------------------
1 0 1 0 1 0 0 Sum
Binary Subtraction
° We can also perform subtraction (with borrows in p lace of carries).
° Let’s subtract (10111) 2 from (1001101)2…
1 10 borrows
0 10 10 0 0 10
Minuend
1 0
0 1 1 0 1
- 1 0 1 1 1 Subtrahend
------------------------
Difference
1 1 0 1 1 0
Binary Multiplication
Binary multiplication is much the same as decimal multiplication, except
that the multiplication operations are much simpler…
1
0 1 1 1 Multiplicand
X 1 0 1 0 Multiplier
-----------------------
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
-----------------------
1 1 1 0 0 1 1 0 Product
Complements
• Used to simplifying the subtraction
• Simplification lead to simpler and less expensive circuits
to implement
Radix / Base r 2 10
Radix complement r 2 10
Diminished radix complement r-1 1 9
Complements
999999
– 9’s complement -546700
• Subtract each digit from 9
453299
– 10’s complement
• Subtract each digit from 9 and add 1 to the result
• Subtract the first non zero from 10 and all others from 9
• Count the number of digit and subtract from 10n
999999
-546700 9 9 9 10 - -
1000000
453299 -5 4 6 7 0 0
- 546700
+ 1 453 3 00
453300
453300
Complements
– 1’s complement 1111111
– Find the inverse of the given number 1011000
0100111
– 2’s complement
– Find the inverse of the given number and add 1 to the result
– Keep the first non zero as such and then complement the others
– Count the number of digit and subtract from 2n
1111111
1011000 1112 - - -
10000000
0100111 -1 0 1 1 0 0 0
-1011000
+ 1 0 101000
0101000
0101000
Subtraction with r’s Complement
+ 52532
9’s comp 96749 + 52532
149281 10’s comp 96750
(carry Positive , 9’s comp so add
149282
carry) 1
(carry Positive , 10’s comp so
49282
discard carry)
49282
Subtraction with Complement
• 3250 - 52532
Radix 52532 3250
R-1 47467 96749
R 47468 96750
+ 03250 + 03250
9’s comp 47467 10’s comp 47468
50717 50718
(No carry , negative (No carry , negative
Find 9’s complement ) Find 10’s complement )
- 49282 -49282
Subtraction with Complement
• 1010100 – 1000011
Radix 1010100 1000011
R-1 0101011 0111100
R 0101100 0111101
+ 1010100
1’s comp 0111100
10010000 + 1010100
(carry Positive , 1’s comp so add carry) 2’s comp 0111101
1
10010001
0010001
(carry Positive , 2’s comp so discard
carry)
0010001
Subtraction with Complement
• 1000011 – 1010100
Radix 1010100 1000011
R-1 0101011 0111100
R 0101100 0111101
+1000011 +1000011
1’s comp 0101011 2’s comp 0101100
1101110
1101111
(No carry , negative
Find 1’s complement ) (No carry , negative
-0010001 Find 2’s complement )
-0010001
Signed Binary Numbers
Sign Magnitude
bit
Number : 10101
Signed: 10101 = -5
Unsigned : 10101 = 21
Signed Binary Numbers
• Representation:
Signed Binary Numbers
September 5, 2003
Signed Binary Numbers
■ Arithmetic Addition
signed-magnitude Addition
The addition of two numbers in the signed-magnitude system follows the rules
of ordinary arithmetic.
If the signs are the same, we add the two magnitudes and give the sum the
common sign.
If the signs are different, we subtract the smaller magnitude from the larger
and give the difference the sign of the larger magnitude.
Negative numbers are changed into positive numbers using r’s complement
+6 00000110
-13 11110011
-6 11111010
-7 11111001 -6 11111010
+13 00001101
sign bit 1 so find 2’s comp. -13 11110011
+7 100000111
-19 111101101
Discard carry, sign bit 0
Discard Carry
sign bit 1 so find 2’s comp.
Complete Post class Assignment