cit 1101 lec 02

31
Number Systems and Number Systems Conversions Lecture 2

Upload: sohag-sikder

Post on 06-Apr-2017

183 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Cit 1101 lec 02

Number Systems and Number Systems Conversions

Lecture 2

Page 2: Cit 1101 lec 02

2

Number System As a human, we are familiar with a

number system, known as decimal system, but computer is a machine, which use another kind of number system known as binary system. Computer also use Octal and Hexadecimal system, these are update of Binary System.

Page 3: Cit 1101 lec 02

3

Number System

Binary Decimal Octal Hexadecimal

Types of Number System

Page 4: Cit 1101 lec 02

4

Number Systems Base Each number system has a base, which

indicates the number of different symbols used in that system. In the case of the decimal system, this base is 10 since there are ten different symbols used to show quantities in that system (0,1,2, etc, up to 9).

Page 5: Cit 1101 lec 02

5

Base of Different Number Systems

Number system Base Corresponding digit

Binary 2 0 and 1

Octal 8 0, 1, 2, 3, 4, 5, 6, and 7

Decimal 10 0, 1, to 9

Hexadecimal 16 0 to 9 and A to F

Page 6: Cit 1101 lec 02

6

Binary The base of the binary system is 2 so

starting from the unit column (the least significant position) and working to the left, each place value will be two times greater than its predecessor. Thus the positional values are 1, 2, 4, 8,16, 32, 64, etc.

Page 7: Cit 1101 lec 02

7

0 / 1 bit [There are only two bits for binary system] 4 bits = 1 Nibble 8 bits = 1 byte 16 bits = 2 bytes = 1 word 32 bits = 4 bytes = 1 long word 1024 bytes = 1 KB (Kilo Byte) 1024 KB = 1 MB (Mega Byte) 1024 MB = 1 GB (Giga Byte) 1024 GB = 1 TB (Tera Byte) 1024 TB = 1 PB (Peta Byte) 1024 PB = 1 EB (Exa Byte) 1024 EB = 1 JB(Jeta Byte)

Binary Information Representations

Page 8: Cit 1101 lec 02

8

Binary Information Representations

Page 9: Cit 1101 lec 02

9

Bit

Bit: A binary digit is called a bit. Usually expressed as 0 and 1 the two numbers of the binary number system. A bit is the smallest unit of information a computer can use.

Page 10: Cit 1101 lec 02

10

Byte Byte: A group of 8 bits are in a byte. With

8 bits ( binary digits ), there exists 256 possible denary combinations.1 byte of memory can normally hold one of the following: a single alphabetical letter (upper or lower case), a single number 0-9 a symbol ( _ + £ # > etc a further 127 alternative characters. These could be

the letters used in foreign languages, lines to produce boxes etc.

Page 11: Cit 1101 lec 02

11

How Number System Work?

Power of the base 104 103 102 101 100

Calculation 10x10x10x10 10x10x10 10x10The value of

the base number

Any number to the power 0 is always 1

Position value 10,000 1000 100 10 1

Enter Number 2 5 6

Required Calculation     100x2 10x5 1x6

This equals     200 50 6

Add the 3 results 200 + 50 + 6 = 256

Representation of Decimal Number

Page 12: Cit 1101 lec 02

12

Representation of Binary Number Binary Value of 110101 would be represented as shown in the table.

Power of 2 25 24 23 22 21 20

Positional Value 32 16 8 4 2 11 1 0 1 0 1

So by multiplying positional values by the binary values and adding them up:1 * 32 = 32

1 * 16 = 16

0 * 8 = 0

1 * 4 = 4

1 * 0 = 0

1 * 1 = 1

Total = 32 + 16 + 4 + 1 = 53

So if the number 53 was stored in a numeric form internally in a computer itWould be stores as 110101.

Page 13: Cit 1101 lec 02

13

Binary to Decimal Conversion Number 1 1 0 1

ON/OFF ON ON OFF ON

Exponential Expression 23*1 22*1 0 20*1

Calculated Exponent 8*1 4*1 0 1*1

Solved Multiplication 8 4 0 1

Add to Calculate Decimal Value 8+4+0+1=13

Page 14: Cit 1101 lec 02

14

Binary to Decimal Conversion

Number 1 0 1 1 0 1

ON/OFF ON OFF ON ON OFF ON

Exponential Expression 25*1 0 23*1 22*1 0 20*1

Calculated Exponent 32*1 0 8*1 4*1 0 1*1

Solved Multiplication 32 0 8 4 0 1

Add to Calculate Decimal Value 32+0+8+4+0+1=45

Page 15: Cit 1101 lec 02

15

Octal The base of the octal system is 8 and the

place values move left from the least significant position 1, 8, 64, 512, 4096, etc.

Page 16: Cit 1101 lec 02

16

Octal to Decimal ConversionOctal Value of 3056 would be represented as shown in the table.

Power of 8 84 83 82 81 80

Positional Value 4096 512 64 8 13 0 5 6

Multiplying values and adding them up:

3 * 512 = 1536

0 * 64 = 0

5 * 8 = 40

6 * 1 = 6

Total = 1582

Page 17: Cit 1101 lec 02

17

Hexadecimal The base of the hexadecimal system is

16 and the place values move left from the least significant position 1, 16, 256, 4096, etc.

Page 18: Cit 1101 lec 02

18

Hexadecimal to Decimal Conversion

Hexadecimal Value of 2FA6 would be represented as shown in the table.

Power of 16 163 162 161 160

Positional Value 4096 256 16 12 F A 6

Multiplying values and adding them up:2 * 4096 = 8192

F (15) * 256 = 3840

A (10) * 16 = 160

6 * 1 = 6

Total = 12198

Page 19: Cit 1101 lec 02

19

Number Base Conversions In the conversion from decimal to any other

number base is simply to divide the base into the decimal number, note the remainder, then divide the base into the quotient and keep repeating this process until there is a zero quotient. Reading off the remainders in the reverse order of them being written down will produce the required answer.

Page 20: Cit 1101 lec 02

20

Decimal to Binary conversion Convert Decimal number 117 into Binary number:

Quotient Divide by Result Remainder117 2 58 158 2 29 029 2 14 114 2 7 07 2 3 13 2 1 11 2 0 1Reading the remainder column from the bottom up we see that 117 Decimal = 1110101 in Binary

Page 21: Cit 1101 lec 02

21

Decimal to Octal conversion

Convert Decimal number 236 to Octal number:

Quotient Divide by Result Remainder236 8 29 429 8 3 53 8 0 3

Reading the remainder column from the bottom up we see that 236 Decimal = 354 in Octal

Page 22: Cit 1101 lec 02

22

Decimal to Hexadecimal conversion

Convert Decimal number 473 to hexadecimal number:

Quotient Divide by Result Remainder473 16 29 929 16 1 D1 16 0 1

Reading the remainder column from the bottom up we see that 473 Decimal = 1D9 in Hexadecimal

Page 23: Cit 1101 lec 02

23

Non-Decimal Conversions

Page 24: Cit 1101 lec 02

24

Binary to Octal

Binary 000 001 010 011 100 101 110 111

Octal 0 1 2 3 4 5 6 7

Convert binary 101010110001 to octal:

• Split the number up into groups of three:

Binary 101 010 110 001

• Now write down the equivalent octal from the table:

Octal 5 2 6 1

Page 25: Cit 1101 lec 02

25

Octal to Binary Convert octal 2743 to binary

Octal 2 7 4 3 Binary 010 111 100 011

Page 26: Cit 1101 lec 02

26

Binary to HexadecimalBinary Hexadecimal Binary Hexadecimal0000 0 1000 80001 1 1001 90010 2 1010 A0011 3 1011 B0100 4 1100 C0101 5 1101 D0110 6 1110 E0111 7 1111 F

Convert binary 11010111011 to hexadecimal:Binary 0110 1011 1011Hexadecimal 6 B B

Page 27: Cit 1101 lec 02

27

Hexadecimal to Binary Convert hexadecimal 9AC to binary

Hexadecimal 9 A C

Binary 1001 1010 1100

Page 28: Cit 1101 lec 02

28

Ternary  210     Class Work

Decimal Octal Binary Hexadecimal25

77101101010111

AF3

Page 29: Cit 1101 lec 02

29

Ternary  210      Class Work (Solve)

Decimal Octal Binary Hexadecimal25 31 11001 1963 77 111111 3F

2903 5527 101101010111 B572803 5363 101011110011 AF3

Page 30: Cit 1101 lec 02

30

Homework Questions Convert the following decimal numbers to binary : 65,

127, 512 Convert the following binary numbers to decimal :

1001110, 1110011, 1111110 Convert the following decimal numbers to octal : 265,

450, 1024 Convert the following octal numbers to decimal : 546,

127, 447 Convert the following decimal numbers to

hexadecimal : 265, 450, 1024

Page 31: Cit 1101 lec 02

31

Homework Questions Convert the following hexadecimal numbers to decimal :

2A5, ABF, 19C

Convert the following binary numbers to octal : 100, 111111, 1110111011101

Convert the following octal numbers to binary : 358, 5614 , 37506

Convert the following binary numbers to hexadecimal : 11011 , 1110001011 , 1011001011001

Convert the following hexadecimal numbers to binary : F2B, C12, FF1F