0% found this document useful (0 votes)
70 views96 pages

Number System

The document discusses different number systems including decimal, binary, octal, and hexadecimal. It explains how each system works using different bases and allowed digits. Conversion between these number systems is also covered through examples like converting a binary number to decimal or a decimal number to octal.

Uploaded by

nancy_007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views96 pages

Number System

The document discusses different number systems including decimal, binary, octal, and hexadecimal. It explains how each system works using different bases and allowed digits. Conversion between these number systems is also covered through examples like converting a binary number to decimal or a decimal number to octal.

Uploaded by

nancy_007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 96

Amity School of Engineering and Technology

Number System
Number System
• Decimal Number System
• Binary Number System
• Octal Number System
• HexaDecimal Number System

2
Decimal Number System

• The number system that we use in our


day-to-day life is the decimal number
system. Decimal number system has base
10 as it uses 10 digits from 0 to 9.
• In decimal number system, the successive
positions to the left of the decimal point
represents units, tens, hundreds,
thousands and so on.

3
Decimal Number System
• Each position represents a specific power
of the base (10).
• For example, the decimal number 1234
consists of the digit 4 in the unit's position,
3 in the tens position, 2 in the hundreds
position, and 1 in the thousands position,
and its value can be written as
=((4 × 1) + (3 × 10) + (2 × 100) + (1 × 1000))
=1234
4
Binary Number System
• Uses two digits, 0 and 1.
• Also called base 2 number system
• First position in a binary number
represents a 0 power of the base (2).
• Example: 20
• Last position in a binary number
represents an x power of the base (2).
• Example: 2x where x represents the last
position - 1.
5
Octal Number System
• Uses eight digits, 0,1,2,3,4,5,6,7.
• Also called base 8 number system
• First position in an octal number
represents a 0 power of the base (8).
Example: 80
• Last position in an octal number
represents an x power of the base (8).
• Example: 8x where x represents the last
position - 1.
6
Hexadecimal Number System
• Uses 10 digits and 6 letters,
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
• Letters represents numbers starting from 10. A =
10, B = 11, C = 12, D = 13, E = 14, F = 15.
• Also called base 16 number system.
• First position in a hexadecimal number
represents a 0 power of the base (16). Example
160.
• Last position in a hexadecimal number
represents an x power of the base (16). Example
16x where x represents the last position - 1.
7
Values of Each Digit
• A value of each digit in a number can be determined
using
• The digit
• The position of the digit in the number
• The base of the number system (where base is defined
as the total number of digits available in the number
system).
Number System
S.No. Number System Base Digits
1 Decimal number system 10 0-9
2 Binary Number System 2 0-1

3 Octal Number System 8 0-7

4 Hexa Decimal Number 16 0-9 & A-F


System Numeric
Equivalent
A-10
B-11
C-12
D-13
E-14
F-15

9
Number System Conversions

• Binary ()2 to Decimal ()10


• Octal ()8 to Decimal ()10
• Hexa Decimal ()16 to Decimal ()10

10
Binary ()2 to Decimal ()10
• In the binary number
system, the weight of
each digit increases
by a factor of 2
• First digit has a
weight of 1 ( 20 ), the
second digit has a
weight of 2 ( 21 and
so on.

11
Binary ()2 to Decimal ()10
• (10101)2 to ()10
Step 1: Multiply each digit by base from LSB and take power starting

from 0

=((1 × 20) + (0 × 21) + (1 × 22) + (0 × 23) + (1


× 24))10
Step 2: Perform the mathematical calculation

=((1 × 1) + (0) + (1 × 4) + (0) + (1 × 16))10


=((1) + (0) + (4) + (0) + (16))10
=(21)10 12
Binary ()2 to Decimal ()10
• Fractional digits to the
right of the binary
point have respective
weightings
• The weightings are
negative powers of
two, creating a binary
fraction i.e. 2-1, 2-2, 2-3,
2-4

13
Binary ()2 to Decimal ()10

(1101.0111)2 to ()10
1101.0111 = (1×20) + (0×21) + (1×22) + (1×23)
+ (0×2-1) + (1×2-2) + (1×2-3) + (1×2-4)
= 1 + 0 + 4 + 8 + 0 + 1/4 + 1/8 + 1/16
= 1 + 0 + 4 + 8 + 0 + 0.25 + 0.125 + 0.0625
= 13.437510

14
Binary ()2 to Decimal ()10
(1011.111)2 to ()10
1011.111 = (1×20) + (1×21) + (0×22) +
(1×23) + (1×2-1) + (1×2-2) + (1×2-3)
= 1 + 2 + 0 + 8 + 0.5 + 0.25 + 0.125
= 11.87510

11.001 = (1×20) + (1×21) + (1×2-3)


= 1 + 2 + 0.125 = 3.12510

15
Octal ()8 to Decimal ()10
• Base of an Octal
Numbers system
is 8 (base-8)
• octal number system
uses only eight digits
(0 through 7)

16
Octal ()8 to Decimal ()10

• (232)8 to ()10
=( 2×80 ) + ( 3×81 ) + ( 2×82)
=2x1 + 3x8 + 2x64
=2+24+128 =154
• (1576)8 to ()10
=1x8 3
+ 5x82
+ 7x81
+ 6x80

=
1x512 + 5x64 + 7x8 + 6x1
=512 + 320 + 56 + 6 = 894
17
Octal ()8 to Decimal ()10

18
Octal ()8 to Decimal ()10

• (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
Octal ()8 to Decimal ()10

• (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
Hexa Decimal ()16 to
Decimal ()10
(AB34)₁₆ = (?)₁₀
= (4 × 16⁰) + (3 × 16¹) + + (B × 16²) + (A × 16³)
= (4 × 16⁰) + (3 × 16¹) + (11 × 16²) + (10 × 16³)
=(4 × 1) + (3 × 16) + (11 × 256) + (10 × 4096)
=4+48+2816+40960
= (43828)₁₀

21
Hexa Decimal ()16 to
Decimal ()10
( EF.B1)16= ( ? )10
=E x 161 + F x 160 + B x 16-1 + 1 x 16-2
= 14 x 16 + 15 x 1 + 11 x ( 1 / 16 ) + 1 x
( 1 / 256 )
= 224 + 15 . ( 0. 6 8 7 5 ) + ( 0 . 0 0 3 9 0 6
25)
= 239 + 0. 6914
= 239 . 691406
22
Test Your Understanding
• (10111.1101)2 to ()10
• (247.35)8 to ()10
• (A214.9E)16 to ()10

Answer
• (10111.1101)2 to (23.8125)10
• (247.35)8 to (167.453125)10
• (A214.9E)16 to (41492.6171875)10
23
Number System Conversions

• Decimal ()10 to Binary ()2


• Decimal ()10 to Octal ()8
• Decimal ()10 to Hexa Decimal ()16

24
Decimal ()10 to Binary ()2
• Write down the decimal number and
continually divide-by-2 (two) to give a
result and a remainder of either a “1” or a
“0” until the final result equals zero.

25
Decimal ()10 to Binary ()2
• Convert =

• =(

26
Decimal ()10 to Binary ()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
Decimal ()10 to Binary ()2

Step-2 Discard the whole number part of


the previous result (1 in this case) and
multiply by 2 once again
.25 x 2 = 0.50
So,.625 = .10??

28
Decimal ()10 to Binary ()2

Step -3 Discard the whole number part of


the previous result (.50 in this case) and
multiply by 2 once again
.50 x 2 = 1.00
So,.625 = .101?
We are finished in Step 3, because we had
0 as the fractional part of our result there.
So, =
29
Decimal ()10 to Binary ()2

Infinite Binary Fractions


Convert =
Step1. .1 x 2 = 0.2
Step 2. .2 x 2 = 0.4
Step 3. .4 x 2 = 0.8
Step 4. .8 x 2 = 1.6
Step 5. .6 x 2 = 1.2

30
Decimal ()10 to Binary ()2

Infinite Binary Fractions


Step 6. We multiply by 2 once again,
discarding the whole number part of the
previous result. Notice that this next step to
be performed (multiply .2 x 2) is exactly the
same action we had in step 2.
In other words, we will never get a 0 as the
decimal fraction part of our result. Instead
we will just cycle through steps 2-5 forever.
31
Decimal ()10 to Binary ()2

Infinite Binary Fractions


So, =

32
Decimal ()10 to Octal ()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
Decimal ()10 to Octal ()8

Hence, by continuously dividing the decimal


number by 8 we get

So,=
34
Decimal ()10 to Octal ()8
• To convert a decimal fraction to octal,
multiply by 8;
• the integer part of the result is the first digit
of the octal fraction.
• Repeat the process with the fractional part
of the result, until it is null or within
acceptable error bounds.

35
Decimal ()10 to Octal ()8
• =
×8=1.3125
0.3125×8=2.5
0.5×8=4.0
So, =

36
Decimal ()10 to Octal ()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, =
37
Decimal ()10 to Hexa
Decimal ()16
• First, divide the decimal number by 16,
• Keep aside the remainder left.
• Again divide the quotient by 16 and repeat
till you get the quotient value equal to
zero.
• Now take the values of the remainder’s in
the reverse order to get the hexadecimal
numbers.

38
Decimal ()10 to Hexa
Decimal ()16
=

Read from the bottom (MSB) to top (LSB)


as 3C0
=

39
Decimal ()10 to Hexa
Decimal ()16
• To convert a decimal fraction to
hexadecimal, multiply by 16;
• The integer part of the result is the first
digit of the hexadecimal fraction.
• Repeat the process with the fractional part
of the result, until it is null or within
acceptable error bounds.

40
Decimal ()10 to Hexa
Decimal ()16
=
1. 0.06640625 x 16=1.0625
2. 0.0625 x 16 =1.0
3. 0 x 16=0.0

41
Test Your Understanding

• (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
42
Octal ()8 to Binary ()2

43
Binary ()2 to Octal ()8
• Starting from the LSB, make groups of
three bits.
• If there are one or two bits less in making
the groups, 0s can be added after the
MSB
• Convert each group into its equivalent
octal number

44
Binary ()2 to Octal ()8

So, (010110010101)2 =(2625)8

45
Octal ()8 to Binary ()2

• (145)8=(?)2
=(001 100 101)8
=(1100101)8
• (352.563)8=(?)2
=(011 101 010.101 110 011)2
=(011101010.101110011)2

46
Test your Understanding

• (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
Binary to Hexadecimal
• Starting from the LSB make groups of four
bits.
• If there are one or two bits less in making
the groups, 0s can be added after MSB.
• Convert each group into its equivalent
octal number.

49
Hexa decimal()16 to Binary ()2

• (2C1)16 = (001011000001)2
• (9DB2)16 = (1001110110110010)2

50
Test your Understanding

• (234.56)16=(?)2
• (124.05)16=(?)2

Answer

• (234.56)16=(1000110100.01010110)2
• (124.05)16=(100100100.00000101)2
51
BCD (Binary Coded Decimal)

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

52
Binary Arithmetic
• The arithmetic of binary numbers means
the operation of binary
addition, binary subtraction, binary multi
plication and binary division.

53
Binary Addition
• There are four steps in binary addition
they are written below
• 0+0=0
• 0+1=1
• 1+0=1
• 1 + 1 = 0 (carry 1 to the next significant bit)

54
Example
• 100101 + 10101 = ?.

So, 100101 + 10101 = 1 1 1 0 1 0

55
Example
• 10111 + 110001=?
• 1011001 + 111010=?

56
Binary Subtraction
• Rules
0-0=0
1-0=1
1-1=0
0 - 1 = 1 with a borrow of 1

57
Test Your Understanding
• Subtract 1111010 from 100010110
• Subtract 100111 from 101101

58
Binary Multiplication
• The rules of binary multiplication are:
0×0=0
0×1=0
1×0=0
1 × 1 = 1 [No borrow or carry method is
applicable here]

59
Example
• 9×5 (1001 × 101)

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

60
Binary Division
• The main rules of the binary division
include:
• 1÷1 = 1
• 1÷0 = Meaningless
• 0÷1 = 0
• 0÷0 = Meaningless

61
Example

62
Binary Number Representation
• Unsigned Representation
• Signed Representation

63
Unsigned Representation
• Non negative numbers can be represented
• Number>=0
• Negative numbers cannot be represented
• Example- age, no of children in class

64
Signed representation
• All integers can be represented
• Nos can be positive, negative or zero
• example-temperature, product of two nos

65
Ways to Represent Signed
Numbers
• Sign and magnitude (SNM)
• 1’s complement
• 2’s complement

66
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

67
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)

2’s complement (all 8 -4 +3


representation)

68
8-bit Number
• =256
Unsigned-0 to 255
Signed and Magnitude- -127 to +127
1’s complement- -127 to +127
2’s complement- -128 to +127
• =1024
Unsigned-0 to 1023
Signed and Magnitude- -511 to +511
1’s complement- -511 to +511
2’s complement- -512 to 511
69
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

70
Addition by 1’s Complement

Case 1:Addition of the positive number with


a negative number when the positive
number has a greater magnitude
In this case, calculate the 1's complement of the
given negative number. Add this with the given
positive number. If we are getting the end-
around carry 1, it gets added to the LSB.

71
Addition by 1’s Complement
• Case 2: Addition of positive and
negative number when negative
number has greater magnitude.
When the negative number has greater
magnitude, then take 1’s complement of
negative number and add with given positive
number. Since there will not be any end-
around carry bit, so take 1’s complement of
the result and this result will be negative.
72
Addition by 1’s Complement
• Case 3: Addition of two negative numbers
You need to take 1’s complement for both
numbers, then add these 1’s complement of
numbers. Since there will always be end-
around carry bit, so add this again to the
LSB of result. Now, take 1’s complement
also of previous result, so this will be
negative number.

73
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

74
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)
75
2’s Complement
• Now as you all are familiar with 1’s and 2’s
complement , understand the significance
of 2’s complement. Take example of 2’s
complement of -50
Decimal Unsigned Sign and 1’s 2’s
Number Magnitude complement complement
(1’s
complement
+1)
- 50 Cannot be 1 110010 1 001101 1 001110
represented

76
2’ Complement
• 2’ complement of -50 is 1 001110

=32 =16 =8 =4 =2 =1
Bit (
1 0 0 1 1 1 0

• So 2’s complemented for -50 =


-64+8+4+2=-64+14=-50
77
Overflow/underflow
• Consider a 4-bit unsigned number . Range
for unsigned number is 0 to 15

1 1
0 1 1 1 =7
0 1 1 0 =6
1 1 0 1 =13

78
Overflow/underflow

Consider an example to add 15 and 10 in


unsigned representation

1 1
1 1 1 1 =15
1 0 1 0 =10
1 1 0 0 1 =9/25

79
Overflow/underflow

Consider example for signed representation

1 0 0 0 =-8(2’s complement)
1 0 0 1 =-7 (2’s complement)
0 0 0 1 =1 (2’s complement)

80
Example
• Adding one positive and one negative
number will never cause overflow or
underflow In the example shown below
10+(-16) in 2’s complement is represented

10= 0 1 0 1 0
-16= 1 0 0 0 0
1 1 0 1 0
-6=

81
Memory Storage unit

82
Bit
• The smallest unit of data in a computer is
called Bit (Binary Digit). A bit has a single
binary value, either 0 or 1.
• stored as either above or below a
designated level of electrical charge in a
single capacitor within a memory device.

83
Nibble
• Half a byte is nibble

84
Byte
• In most computer systems, a byte is a unit
of data that is eight binary digits long. A
byte is the unit most computers use to
represent a character such as a letter,
number or typographic symbol .
• In some computer systems, four bytes
constitute a word, a unit that a computer
processor can be designed to handle
efficiently as it reads and processes each
instruction 85
Octet
• In some systems, the term octet is used
for an eight-bit unit instead of byte. In
many systems, four eight-bit bytes or
octets form a 32-bit word.

86
Kilobyte
• A Kilobyte (kb or Kbyte) is approximately
a thousand bytes (actually, 2 to the
10th power, or decimal 1,024 bytes).

87
Megabyte
• measure of computer processor storage
and real and virtual memory
=1,048,576 bytes
• Abbreviated as MB.

88
Gigabyte
• A Gigabyte is a measure of computer
data storage capacity and is “roughly” a
billion bytes.
=1,073,741,824 bytes

89
Terabyte
• A Terabyte is a measure of computer
storage capacity

90
Petabyte
• A Petabyte (PB) is a measure of memory
or storage capacity
bytes

91
Exabyte
• An Exabyte (EB) is a large unit of
computer data storage
bytes

92
Zettabyte
• A Zettabyte (ZB) is equal to one sextillion
bytes.
• No storage has ZB storage as of now
• It has 1024 Exabyte of storage

93
Yottabyte
• A Yottabyte is equal to one septillion
bytes
• It has 1024 Zettabyte of storage

94
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

95
Thank You

You might also like