Professional Documents
Culture Documents
Number System
Number System
1
Amity Business School
2
Amity Business School
3
Amity Business School
4
Amity Business School
Number System
S.No. Number System Base Digits
1 Decimal number system 10 0-9
2 Binary Number System 2 0-1
10
5
Amity Business School
11
6
Amity Business School
13
(1101.0111)2 to ()10
1101.0111 = (1×20) + (0×21) + (1×22) + (1×2
3) + (0×2-1) + (1×2-2) + (1×2-3) + (1×2-4)
14
7
Amity Business School
15
• Base of an Octal
Numbers system
is 8 (base-8)
• octal number system
uses only eight digits
(0 through 7)
16
8
Amity Business School
• (232)8 to ()10
=( 2×80 ) + ( 3×81 ) + ( 2×82)
=2x1 + 3x8 + 2x64
=2+24+128 =154
• (1576)8 to ()10
3 2 1 0
=1x8 + 5x8 + 7x8 + 6x8
=1x512 + 5x64 + 7x8 + 6x1
18
9
Amity Business School
• (7.12172)8 to (?)10
= (7×80)+ (1×8-1) + (2×8-2) + (1×8-3)+ (7×8-
4) + (2×8-5)
=7+0.125+0.03125+0.001953125+0.001708
984375+0.00006103515624
=10.1599..
=10.16(approx.)
19
• (152.54)8 to (?)10
= (2 × 8⁰) + (5 × 8¹) + (1 × 8²) + (5 × 8⁻¹) + (4
× 8⁻²)
=2 ×1 + 5 ×8+1 × 64 +5 ×0.125+4 ×0.015625
=106.6875
20
10
Amity Business School
21
11
Amity Business School
Answer
• (10111.1101)2 to (23.8125)10
• (247.35)8 to (167.453125)10
• (A214.9E)16 to (41492.6171875)10
23
24
12
Amity Business School
25
• (52)10 =(110100)2
26
13
Amity Business School
• (0.625)10 =(? )2
Step-1 Begin with the decimal fraction and
multiply by 2. The whole number part of the
result is the first binary digit to the right of
the point.
.625 x 2 = 1.25, the first binary digit to the
right of the point is a 1. So far, we have .625
= .1??? .
27
28
14
Amity Business School
30
15
Amity Business School
32
16
Amity Business School
(567)10 =(? )8
Step 1 Divide 567 by 8
Step 2 Continue dividing the quotient by 8
until you get a quotient of zero
Step 3 Finally write the remainders in the
reverse order to get octal equivalent of
decimal number 567
33
So,(567)10 =(1067)8
34
17
Amity Business School
35
• (0.1640625)10 =(? )8
0.1640625×8=1.3125
0.3125×8=2.5
0.5×8=4.0
So, (0.1640625)10 =(.124)8
36
18
Amity Business School
• (7.16)10 =(? )8
(7)10 =(7)8
0.16×8=1.28
0.28×8=2.24
0.24×8=1.92
0.92×8=7.36
0.36×8=2.88
So, (7.16)10 =(7.12172. . )8
37
38
19
Amity Business School
39
40
20
Amity Business School
(0.06640625)10 =(.110)16
41
• (296.5)10 to ()2
• (813.24)10 to ()8
• (479.36)10 to ()16
Answer
• (296.5)10 to (100101000.1)2
• (813.24)10 to
(1455.17270243656050753412)8
• (479.36)10 to
(1DF.5C28F5C28F5C28F5C28F)16 42
21
Amity Business School
43
44
22
Amity Business School
45
• (145)8=(?)2
=(001 100 101)8
=(1100101)8
• (352.563)8=(?)2
=(011 101 010.101 110 011)2
=(011101010.101110011)2
46
23
Amity Business School
• (234.56)8=(?)2
• (124.05)8=(?)2
Answer
• (234.56)8=(10011100.101110)2
• (124.05)8=(1010100.000101)2
47
Hexadecimal Binary
Number Number
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
48
24
Amity Business School
49
50
25
Amity Business School
Binary to Hexadecimal
51
• (2C1)16 = (001011000001)2
• (9DB2)16 = (1001110110110010)2
52
26
Amity Business School
• (234.56)16=(?)2
• (124.05)16=(?)2
Answer
• (234.56)16=(1000110100.01010110)2
• (124.05)16=(100100100.00000101)2
53
BCD
Decimal digit
8 4 2 1
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
54
27
Amity Business School
Binary Arithmetic
55
Binary Addition
56
28
Amity Business School
Example
• 100101 + 10101 = ?.
57
Example
• 10111 + 110001=?
• 1011001 + 111010=?
58
29
Amity Business School
Binary Subtraction
• Rules
0-0=0
1-0=1
1-1=0
0 - 1 = 1 with a borrow of 1
59
60
30
Amity Business School
Binary Multiplication
61
Example
1 0 0 1
× 1 0 1
1 0 0 1
0 0 0 0
1 0 0 1
1 0 1 1 0 1
62
31
Amity Business School
Binary Division
63
Example
64
32
Amity Business School
• Unsigned Representation
• Signed Representation
65
Unsigned Representation
66
33
Amity Business School
Signed representation
67
68
34
Amity Business School
Example
Decimal Unsigned Sign and 1’s 2’s
Number Magnitude complement complement(
1’s
complement
+1)
+10 1010 0 1010 0 1010 0 1010
-10 … 1 1010 1 0101 1 0110
(shown in
table)
- 25 (6-bit 1 11001 1 00110 1 00111
required)
+ 25 11001 0 11001 0 11001 0 11001
69
Range of Example
From To
Unsigned (total 8 0 7
representation)
Sign and Magnitude -3 +3
(total 7 distinct value, 0
repeated)
1’s complement (total 7 -3 +3
distinct value, 0
repeated)
70
35
Amity Business School
8-bit Number
• 28 =256
Unsigned-0 to 255
Signed and Magnitude- -127 to +127
1’s complement- -127 to +127
2’s complement- -128 to +127
• 210 =1024
Unsigned-0 to 1023
Signed and Magnitude- -511 to +511
1’s complement- -511 to +511
2’s complement- -512 to 511
71
More Examples
Decimal Unsigned Sign and 1’s 2’s
Number Magnitude complement complement(
1’s
complement
+1)
+ 50 110010 0 110010 0 110010 0 110010
- 50 Cannot be 1 110010 1 001101 1 001110
represented
8 1000 0 1000 0 1000 0 1000
-8 1 1000 1 0111 1 1100
+31 11111 0 11111 0 11111 0 11111
-31 1 11111 1 00000 1 00001
72
36
Amity Business School
73
37
Amity Business School
75
Subtraction by 1’s
Complement
• find the 1's complement of the of the
subtrahend. Change 0 to 1 and vice versa
• add the complement number with the
minuend
• If got a carry, add the carry to its LSB.
Else take 1's complement of the result
which will be negative
76
38
Amity Business School
Example
10101 – 00111
• Take 1's complement of subtrahend
00111, which comes out 11000. Now, sum
them. So,
• 10101+11000 =1 01101.
we get the carry bit 1, so add this to the LSB
of a given result
01101+1=01110(Answer)
77
2’s Complement
78
39
Amity Business School
2’ Complement
Overflow/underflow
1 1
0 1 1 1 =7
0 1 1 0 =6
1 1 0 1 =13
80
40
Amity Business School
Overflow/underflow
1 1
1 1 1 1 =15
1 0 1 0 =10
1 1 0 0 1 =9/25
81
Overflow/underflow
1 0 0 0 =-8(2’s complement)
1 0 0 1 =-7 (2’s complement)
0 0 0 1 =1 (2’s complement)
82
41
Amity Business School
Example
10= 0 1 0 1 0
-16= 1 0 0 0 0
1 1 0 1 0
-6=
83
84
42
Amity Business School
Bit
85
Nibble
86
43
Amity Business School
Byte
Octet
88
44
Amity Business School
Kilobyte
89
Megabyte
90
45
Amity Business School
Gigabyte
91
Terabyte
92
46
Amity Business School
Petabyte
93
Exabyte
94
47
Amity Business School
Zettabyte
95
Yottabyte
96
48
Amity Business School
References
• ANSI 89 – American National Standards Institute, American
National Standard for Information Systems Programming
Language C, 1989.
• Kernighan 78 – B. W. Kernighan and D. M. Ritchie, The C
Programming Language, Prentice-Hall: Englewood Cliffs, NJ,
1978. Second edition, 1988.
• Thinking 90 – C* Programming Guide, Thinking Machines
Corp. Cambridge Mass., 1990.
• Programming in ANSI C, E. Balagurusamy. McGrawHill
• Let Us C, Yashvant Kanetkar, BPB Publications
• Programming in C, Reema Thareja, Oxford University Press
97
Thank You
49