12
ICT Foundation 1 Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved. Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved. Binary and Hexadecimal numbers

Binary and Hexadecimal numbers

Embed Size (px)

DESCRIPTION

Binary and Hexadecimal numbers. Computer and binary numbers. Inside the computer, the binary string (bit string) is used for information processing - PowerPoint PPT Presentation

Citation preview

Page 1: Binary and Hexadecimal numbers

ICT Foundation

1

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Binary and Hexadecimal numbers

Page 2: Binary and Hexadecimal numbers

2

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Computer and binary numbers

• Inside the computer, the binary string (bit string) is used for information processing▪ Based on the use of high and low voltages to

process information, using the binary numbers is easier than using the decimal numbers to make a calculation

▪ To calculate decimal numbers, first, they are converted to binary numbers. The binary numbers are then calculated. Finally, the resulting binary numbers are reconverted to decimal numbers for displaying.

Page 3: Binary and Hexadecimal numbers

3

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Binary number

• Using 0 and 1

Decimal number

0 1 2 3 4 5 6 7

Binary Binary numbernumber 00 11 1010 1111 100100 101101 110110 111111

Page 4: Binary and Hexadecimal numbers

4

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Radix (or Base)

• Radix of Decimal number is 10▪207 ( 10 )= 2×102 + 0×101 + 7×100

• The first digit is 100 (= 1 )• The second digit is 101

• The third digit is 102

• Radix of binary number is 2▪101 ( 2 ) = 1×22 + 0×21 + 1×20

• The first digit is 20 (= 1)• The second digit is 21

Page 5: Binary and Hexadecimal numbers

5

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Using binary number to represent the weather

• One card has front as 0 and back as 1 value.

• To represent 4 types of weather, 2-digit binary number is needed.

sunny 00

rainy 01

snowy 10

cloudy 11

Page 6: Binary and Hexadecimal numbers

6

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

The relation between thebinary number and the amount of information

• One-digit binary number▪ distinguishes 2 kinds of information

• Two-digit binary number▪ distinguishes 4 kinds of information

• Three-digit binary number▪ distinguishes 8 kinds of information

We will study about the amount of information in the 7th lecture

Page 7: Binary and Hexadecimal numbers

7

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Conversion from binary to decimal number

• Calculate the sum of the corresponding power two of weight value for all digits 1 in binary number. (the weight of the left-most digit is 0, the next one is 1…)

1

26

0

25

0

24

1

23

1

22

1

21

1

20

1

27

11001111 ( 2 )= 128 + 64 + 0 + 0 + 8 + 4 + 2 + 1 = 207 ( 10 )

Page 8: Binary and Hexadecimal numbers

8

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Conversion from decimal to binary(Integers)

• Arrange in reverse order of modulo 2

2 ) 207 2 ) 103 2 ) 51 2 ) 25 2 ) 12 2 ) 6 2 ) 3 2 ) 1    0

207 ( 10 ) = 11001111 ( 2 )

Arrange in reverse order

Modulo 2

・・・ 1・・・ 1・・・ 1・・・ 1・・・ 0・・・ 0・・・ 1・・・ 1

Page 9: Binary and Hexadecimal numbers

9

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Conversion from decimal to binary(Fraction)

• Arrange the integer part when multiplying fraction with 2

0.625× 2 1.25

0.25× 2 0.5

0.5× 2 1.0

0.625 ( 10 ) = 0.101 ( 2 )

arrange

Integer part when

multiplying with 2

・・・ 1

・・・ 0

・・・ 1

Page 10: Binary and Hexadecimal numbers

10

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Hexadecimal number

• It’s hard to read the binary number once its number of digits increases.

• One digit of hexadecimal number is combined by 4 digits of binary number.

Decimal number

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Hexadecimal Hexadecimal numbernumber 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF

Used for character coding (lecture 5), displaying colors in web page (lecture 9), programming, etc.

Page 11: Binary and Hexadecimal numbers

11

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Conversion from binary to hexadecimal

number• From the left-most digit, divide to groups

that contains each four digits.

• Convert each 4-digit binary number group to decimal number, and then convert it to hexadecimal.

100

4

4

1110

14

E

0110

6

6

10011100110 ( 2 )= 4E6( 16 )

Page 12: Binary and Hexadecimal numbers

12

Copyright © 2010, IT Gatekeeper Project – Ohiwa Lab. All rights reserved.

Conversion from hexadecimal to decimal

number• Calculate the sum of (weight of each digit *

digit value)

• The left-most digit is 160, the next one is 161…

4E6 ( 16 )=1254 ( 10 )

4

162

E ( =14 )

161

6

160

4E6 ( 16 )= 4×256  +  14×16  +  6×1  = 1254 ( 10 )