Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

Lect3 17 3 2022

Uploaded by

Nermeen Kamel
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lect3 17 3 2022

Uploaded by

Nermeen Kamel
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

Department: Advanced Computing and Artificial

Intelligence
Year: First Year
Course. Information Technology
system 2
Semester: 2nd Term
Academic Year: 2021/2022
Lecture No.: 3
Instructor: Dr. Nermeen Kamel
NUMBER SYSTEM

• Decimal Number System


• Binary Number System
• Octal Number System
• Hexadecimal Number
System
Decimal Numbers base-10 system
Decimal stands for 10
Decimal is the base 10 Number System
It has 10 unique symbols
0123456789
The largest symbol is the base – 1
10 – 1 = 9
9 is the largest symbol in Decimal numbers
Decimal Numbers
1000 100 10 units
4 3 5 6

4000
300
50
+ 6
435610
Decimal Numbers
Weight origin 103 102 101 100
Weights 1000 100 10 1
Number MSD 6 3 6 4 LSD

6000
300
60
+ 4
636410
Binary Numbers base-2 system
Binary stands for 2
Binary is the base 2 number system
It has two unique symbols
0 and 1
The largest symbol in Binary is the base – 1
2–1=1
1 is the largest symbol in the Binary Number system
Binary Numbers
Weight origin 23 22 21 20
Weights 8 4 2 1
Number 1 0 1 12

8
0
2
+1
1110
Counting in Binary

Weight 8 4 2 1 decimal
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
1 0 0 0 8
1 0 0 1 9
1 0 1 0 10
1 0 1 1 11
1 1 0 0 12
1 1 0 1 13
1 1 1 0 14
1 1 1 1 15
Octal Number System base-8 system
Octal stands for Eight
Octal is the base 8 Number System
It has 8 unique symbols
01234567
The largest symbol is the base – 1
8–1=7
7 is the largest symbol in the Octal number system
The octal system is a positional value system, wherein each
octal digit has its own value expressed as a power of 8.
Octal Number System base-16 system
Weight origin 83 8 2 8 1 8 0
Weights 512 64 8 1
Number 2 1 6 78

1024
64
48
+ 7
114310
Hexadecimal Number System base-16
system
Hex = 6 and Decimal = 10 6+10 = 16
Hex is the base 16 Number System
It has 16 symbols
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
It must have 16 UNIQUE Symbols
0123456789 A B C D E F
The largest symbol is 16 – 1 = 15 or F
Hexadecimal Number System
Weight origin 163 162 161 160
Weights 4096 256 16 1
Number 1 2 A F 16

4096
512
160
+ 15
478310
NUMBER CONVERSIONS

CONVERSIONS WITH BINARY


• Decimal To Binary
• Decimal Fraction To Binary
• Binary To Decimal
• Binary Fraction To Decimal
CONVERSIONS WITH BINARY

Decimal To Binary
 To converting decimal to Binary we use Repeated division
method. In this the no. is successively divide by 2 and its
remainder recorded.
 For Example convert decimal to Binary 43 10

2 43
2 21 1 WRITE IN
2 10 1 THIS ORDER

2 5 0 From Down to Up
2 2 1
2 1 0
1 1 Your Answer 4310 = 101011
2
Decimal (Integer) to Binary Conversion

• Divide the number by the ‘Base’ (=2)


• Take the remainder (either 0 or 1) as a coefficient
• Take the quotient and repeat the division

Example: (15)10
Quotient Remainder Coefficient
15/ 2 = 7 1 a0 = 1
7 /2= 3 1 a1 = 1
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (15)10 = (a3 a2 a1 a0)2 = (1111)2

MSB LSB
CONVERSIONS WITH BINARY
Decimal Fraction To Binary
• To Convert a decimal fraction into binary, multiply the
decimal fraction by the base that’s 2. Do untill you will
get zero at fractional part.
• For Example Convert 0.37510 to Binary Integer Part

Multiply(fractional part)0.375 * 2 = 0.750 0 Write


0.75 * 2 = 1.50 1 From
Up to
0.50 * 2 = 1.00 1 Down

Your Answer is 0.37510 = 0.0112


Decimal (Fraction) to Binary Conversion

• Multiply the number by the ‘Base’ (=2)


• Take the integer (either 0 or 1) as a coefficient
• Take the resultant fraction and repeat the division

Example: (0.625)10
Integer Fraction Coefficient
0.625 * 2 = 1 . 25 a-1 = 1
0.25 * 2 = 0 . 5 a-2 = 0
0.5 *2= 1 . 0 a-3 = 1
Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2

MSB LSB
CONVERSIONS WITH BINARY
Binary To Decimal
• To convert Binary to Decimal, Add positional weights or values with
power of 2 start from right side.
• For Example Convert 11011 to Decimal.
1 1 0 1 1
24 23 22 21 20
1 * 24 + 1 * 2 3 + 0 * 2 2 + 1 * 2 1 + 1 * 2 0
= 16 + 8 + 0 + 2 + 1
= 2710 (decimal)
CONVERSIONS WITH BINARY
Binary Fraction To Decimal
• To find binary fraction, take the sum of products of each digit value (0
– 1) and its positional value. Starts from left side.
• For Example convert 0.0101 to Decimal.

. 0 1 0 1

2-1 2-2 2-3 2-4


0 * 2-1 + 1 * 2-2 + 0 * 2-3 + 1 * 2-4
= 0 + 0.25 + 0 + 0.0625
0.01012 = 0.312510 (decimal)
NUMBER CONVERSIONS

CONVERSIONS WITH OCTAL


• Decimal To Octal
• Decimal Fraction To Octal
• Octal To Decimal
• Octal To Binary
• Binary To Octal
CONVERSIONS WITH
Decimal To Octal
OCTAL
• A decimal integer can be converted to octal by repeated-division
method with division factor of 8.
• Example Convert 26610 to Octal
remainder

8 266 2 WRITE IN
8 33 1 THIS ORDER

8 4 4 From Down to Up

0
26610 = 4128
Decimal to Octal Conversion
Example: (173)10
Quotient Remainder Coefficient
173 / 8 = 21 5 a0 = 5
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (255)8

Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
CONVERSIONS WITH
OCTAL
Decimal Fraction To Octal
• To convert Decimal fraction into Octal, multiply fractional part with 8
till you get fractional part 0.
• Example : convert 0.37510 to Octal
Integer Part
Write
0.375 * 8 = 3.0 3 From
Up to
Down
 0.37510 = 0.38
CONVERSIONS WITH OCTAL
Octal To Decimal
• It can easily converted into decimal by multiplying each octal digit by its
positional weight.
• For Example 3728 to Decimal
3 7 2

82 81 80

3 * 82 + 7 * 8 1 + 2 * 8 0
= 3 * 64 + 7 * 8 + 2 * 1
= 25010
CONVERSIONS WITH
Octal To Binary
OCTAL
• To convert Octal To Binary is easy. This converting is performed by
converting each octal digit to its 3 bit binary. Possible digits converted
as indicated in Table
Octal 0 1 2 3 4 5 6 7
Digit
Binary 000 001 010 011 100 101 110 111

• Example : 4728 to binary


From table , 4 = 100 , 7 = 111 & 2 = 010
We get 4728 = 1001110102
CONVERSIONS WITH OCTAL
Binary To Octal
• Its simply the reverse of octal to binary. Make the three bits group
starting from LSB. Then convert it with using Table
Octal 0 1 2 3 4 5 6 7
Digit
Binary 000 001 010 011 100 101 110 111

• For Example: 110101102 to Octal


Make group of three 011 , 010 & 110 Add Zero
To Make it
011 = 3 , 010 = 2 & 110 = 6 group of
3 bit.
110101102 = 3268
Binary − Octal Conversion
Octal Binary
• 8 = 23
• Each group of 3 bits represents an octal 0 000
digit 1 001
2 010
Assume Zeros
Example: 3 011

( 1 1 0 0 1 . 1 1 )2 4 100
5 101
6 110
( 3 1 . 6 )8 7 111

Works both ways (Binary to Octal & Octal to Binary)


NUMBER CONVERSIONS

CONVERSIONS WITH HEX


Decimal To HEX
Decimal Fraction To HEX
HEX To Decimal
HEX To Binary
Binary To HEX
CONVERSIONS WITH
HEX
Decimal To HEX
• A decimal integer can be converted to hex by repeated-division method
with division factor of 16.
• Example Convert 26610 to Hex
remainder

16 423 7 1010 = A16


16 26 A
WRITE IN
16 1 1 THIS ORDER
From Down to Up
0
42310 = 1A716
CONVERSIONS WITH HEX
Decimal Fraction To Hex
• To convert Decimal fraction into Hex, multiply fractional part with 16
till you get fractional part 0.
• Example : convert 0.0312510 to Hex
Integer Part
Write
0. 03125 * 16 =0.5 0 From
0. 5 * 16 = 8.0 8 Up to
Down

 0.0312510 = 0.0816
CONVERSIONS WITH
HEX To Decimal
HEX
• It can easily converted into decimal by multiplying each Hex digit by its
positional weight has power of 16.
• For Example 2AF16 to Decimal
2 A F
Decimal Hex Decimal Hex
0 0 8 8
1 1 16 2
16 1
16 0
9 9
2 2 10 A
3 3 2 * 162 + A * 161 + F * 160 11 B
4 4 12 C
= 2 * 256 + 10 * 8 + 15 * 1
5 5 13 D
6 6 = 60710 14 E
7 7 15 F
CONVERSIONS WITH HEX
HEX To Binary
• To convert Hex To Binary is easy. This converting is performed by
converting each hex digit to its 4 bit binary. Possible digits converted
as indicated in Table
Binary Hex Binary Hex
0000 0 1000 8
Example : 3A616 to binary
0001 1 1001 9
0010 2 From table, 3 = 0011 , 1010 A
0011 3 A = 1010 & 6 = 0110 1011 B
0100 4 1100 C
We get 3A616 = 0011101001102
0101 5 1101 D
0110 6 1110 E
0111 7 1111 F
CONVERSIONS WITH
HEX
Binary To HEX
• Its simply the reverse of Hex to binary. Make the four bits group
starting from LSB. Then convert it with using Table
Add Zero to Make it group
of 4 bit.
Binary Hex • For Example: 10101110102 to HexBinary Hex
0000 0 1000 8
0001 1 Make group of four 0010 1001 9
0010 2 , 1011 & 1010 1010 A
0011 3 1011 B
0010 = 2 , 1011 = B & 1010 = A
0100 4 1100 C
0101 5
10101110102 = 2BA16 1101 D
0110 6 1110 E
0111 7 1111 F
Binary − Hexadecimal Conversion
Hex Binary
• 16 = 24 0 0000
1 0001
• Each group of 4 bits represents a 2 0010
hexadecimal digit 3 0011
4 0100
5 0101
Assume Zeros 6 0110
Example: 7 0111
8 1000
( 1 1 0 0 1 . 0 1 )2 9 1001
A 1010
B 1011
C 1100
D 1101
(1 9 . 4 )16 E 1110
F 1111

Works both ways (Binary to Hex & Hex to Binary)


Octal − Hexadecimal Conversion
• Convert to Binary as an intermediate step
Example:
( 1 5 . 3 )8

Assume Zeros Assume Zeros

( 0 0 1 1 0 1 . 0 1 1 )2

(0 D . 6 )16

Works both ways (Octal to Hex & Hex to Octal)


June 4, 1996

\ l

Stanford
June 4, 1996 0 : 38 • 5 r/ r \

(r((\j))I
\
(r((\j))I
.
'
- I

c
Actual Stored Value I n t e p r e t e d
Year Year
1952 52 1952
1984 84 1984
1995 95 1995
2000 00 1900
2001 01 1901
0:38.5

-.
8-bit 11111111
Unsigned + 1
Range:0-
255
0000000
Thanks

Queries

42

You might also like