14
Dr Md Kabirul Islam Daffodil International University Thursday, June 16, 2022 1

Summer 13 cse 112 2

Embed Size (px)

Citation preview

Page 1: Summer 13 cse 112 2

Dr Md Kabirul IslamDaffodil International University

Wednesday, April 12, 2023 1

Page 2: Summer 13 cse 112 2

Contents of Today Lecture

Number SystemDecimal number systemBinary number systemOctal number systemHexadecimal number system

Wednesday, April 12, 2023 2

Page 3: Summer 13 cse 112 2

Number SystemThere are four number systems used in computer.

These are as follows:Binary Number SystemDecimal Number SystemOctal Number SystemHexadecimal Number System

Wednesday, April 12, 2023 3

Page 4: Summer 13 cse 112 2

BINARY NUMBER SYSTEMThe number system, which has base two, is called binary number system (i.e., it uses only two symbol /digit, viz. 0 and 1, for representing any data). These symbols are called bit. Bit stands for binary digit. To represent a number in binary number system any combination of 0’s and 1’s can be used. e.g., (1101)2, (1101)2, (1100)2, etc.

Wednesday, April 12, 2023 4

Page 5: Summer 13 cse 112 2

NUMBER SYSTEMDECIMAL NUMBER SYSTEM

In this system ten digits are used viz., 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. These digits represent their absolute value as well as values as per the position the occupy in the number. The base of this number system is 10. e.g., (1304)10, (1786)10, (1100)10, etc.

OCTAL NUMBER SYSTEMIn Octal number system, eight symbols / digits are used, viz., 0, 1, 2, 3, 4, 5, 6, and 7. The base of this number system is 8. e.g., (1100)8, (2671)8, (321)8, etc.

HEXADECIMAL NUMBER SYSTEMIn hexadecimal number system, sixteen digits/symbols are used, viz., 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The base of this number system is 16. e.g., (A321)16, (FF)16, (1100)16, etc.

Note: The number such as (1100)2 , (1100)8 , (1100)10 and (1100)16 are not same, because its base is different. You can convert any number of any number system to any number system.

Wednesday, April 12, 2023 5

Page 6: Summer 13 cse 112 2

CONVERSION OF BINARY TO DECIMALYou can convert any binary number to decimal number.

Example 1:

The binary number 1100 is converted into decimal number as follows:

1 x 23 + 1 x 22 + 0 x 21 + 0 x 20

1 x 8 + 1 x 4 + 0 x 2 + 0 x 1 (since 20 = 1)8 + 4 + 0 + 012

therefore, the binary number 1100 is equivalent to decimal number 12.

i.e., (1100)2 = (12)10.

Wednesday, April 12, 2023 6

Page 7: Summer 13 cse 112 2

CONVERSION OF DECIMAL TO BINARY You can convert any decimal number to binary number.

Example 1: The decimal number 12 is converted into binary number as follows:

2 | 12 | 02 | 6 | 02 | 3 | 11therefore, (12)10 = (1100)2.

Example 2: The decimal number 9 is converted into binary number as follows:

2 | 9 | 12 | 4 | 02 | 2 | 01therefore, (9)10 = (1001)2.

Wednesday, April 12, 2023 7

Page 8: Summer 13 cse 112 2

Octal Number SystemBase or radix 8 number system.1 octal digit is equivalent to 3 bits.Octal numbers are 0 to7. Numbers are expressed as powers of 8.

Wednesday, April 12, 2023 8

Page 9: Summer 13 cse 112 2

Conversion of octal to decimalExample: convert (632)8 to decimal

= (6 x 82) + (3 x 81) + (2 x 80)= (6 x 64) + (3 x 8) + (2 x 1)= 384 + 24 + 2= (410)10

Wednesday, April 12, 2023 9

Page 10: Summer 13 cse 112 2

Conversion of decimal to octalExample: convert (177)10 to octal equivalent

177 / 8 = 22 remainder is 122 / 8 = 2 remainder is 62 / 8 = 0 remainder is 2

Answer = 2 6 1

Wednesday, April 12, 2023 10

Page 11: Summer 13 cse 112 2

Hexadecimal Number SystemBase or radix 16 number system.1 hex digit is equivalent to 4 bits.Numbers are 0,1,2…..8,9, A, B, C, D, E, F.B is 11, E is 14Numbers are expressed as powers of 16.160 = 1, 161 = 16, 162 = 256, 163 = 4096

Wednesday, April 12, 2023 11

Page 12: Summer 13 cse 112 2

Conversion of hex to decimalConversion of hex to decimal ( base 16 to

base 10)Example: convert (F4C)16 to decimal= (F x 162) + (4 x 161) + (C x 160)= (15 x 256) + (4 x 16) + (12 x 1)

Wednesday, April 12, 2023 12

Page 13: Summer 13 cse 112 2

Conversion of decimal to hexExample: convert (4768)10 to hex.= 4768 / 16 = 298 remainder 0= 298 / 16 = 18 remainder 10 (A)= 18 / 16 = 1 remainder 2= 1 / 16 = 0 remainder 1

Answer: 1 2 A 0

Wednesday, April 12, 2023 13

Page 14: Summer 13 cse 112 2

Conversion of binary to hexConversion of binary numbers to hex simply

requires grouping bits in the binary numbers into groups of four bits.

Groups are formed beginning with the LSB and progressing to the MSB.

1110 01112 = E716

= 1000 1010 1000 01112

= 1000 1010 1000 01112

= 8 A 8 716

Wednesday, April 12, 2023 14