1/15/2015 slide # 1 binary, octal and hex numbers copyright thaddeus konar introduction to binary,...

27
06/22/22 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

Upload: kelly-moris

Post on 02-Apr-2015

234 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 1

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Introduction to Binary, Octal and Hexadecimal Numbers

Thaddeus Konar

Page 2: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 2

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Decimal Integers

There is nothing ‘unique’ about number 10, but because we have 10 fingers, the decimal notation (from Latin decem and Greek Deka: 10) seems ‘natural’ to us.

If the world would be like Simpsons (and I am glad it is not) the natural notation would be octal (8 fingers)

457678543

965432783745673

01

8934098798347298763287632

09832198798237986498762380236409

Page 3: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 3

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Decimal Integers

Each digit (counting from the right) represents next power of ten, the rightmost digit represents 1s, next digit represents 10s, next 100s, and so on:

…,10000, 1000, 100, 10, 1which is the same as:

…,104 ,103, 102, 101, 100

(Please remember that any number X to zero (0) power equals 1!)

X0 = 1

Page 4: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 4

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Decimal Integers (cont)

7845 means:

(5*1)+(4*10)+(8*100)+(7*1000)

and this is same as:

(5*100)+(4*101)+(8*102)+(7*103)

Page 5: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 5

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Decimal Integers (Cont)

What does 58345 ‘really’ mean:

58345

5 * 1 4 * 103 * 100

=5=40

=3008 * 1000 =8000

5 * 10000 =50000

=58345

Page 6: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 6

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Decimal Integers (cont) Lets look at the properties of the decimal integers:

Base = 10 (1, 10, 100, …) (100, 101 , 102 , …)

Digits range: 0 -> 9 (0,1,2,3,4,5,6,7,8,9)

Number of values represented by a single digit: 10

Please note that number of digits equals Base, and range goes from zero to (Base –1).

Digits range: 0 -> (Base - 1)

Number of values represented by a single digit: Base

Page 7: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 7

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

General NotationAny number is represented by combination of single digits Dx, where x is the position of the digit counting from the right. The value of Dx can be only the digits between (and including) 0 and (Base-1).

…D5D4D3D2D1D0

Using our example decimal number 7845

D0 =5, D1=4, D2=8, and D3 =7

Page 8: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 8

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

General Notation (cont)

We can see that any number really means:

(D0*B0)+(D1*B1)+(D2*B2)+(D3*B3)+…(Dn*Bn)

In our example number 7845 (base 10) means:(5*100)+(4*101)+(8*102)+(7*103)=5+40+800+7000

Page 9: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 9

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Binary Integers 1Just as the each digit (position) in decimal integer is represented by the power of 10, binary integers are numbers where each digit is represented by the power of 2 (Base = 2).

Digits range: 0 -> (Base - 1)Number of values represented by a single digit: Base

Digits range: 0 -> 1 (0,1)Number of values represented by a single digit: 2

Page 10: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 10

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Binary Integers 2

In the decimal number the digits could be 0,1,2,3,4,5,6,7,8,9. (0 -> Base-1). As we can see the binary number digits could only be either 0 or 1 (0 ->Base-1).

The single decimal number can represent 10 values, and the single binary number can represent only 2 values.

Page 11: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 11

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Binary Integers 3

Binary integer will be a combination of 1s and 0s.

Please recall the formula (and remember that now Base=2):

(D0*B0)+(D1*B1)+(D2*B2)+(D3*B3)+…(Dn*Bn)

Lets look at the binary number 101110

D0=0, D1=1, D2=1, D3=1, D4=0, D5=1

B0=1, B1=2, B2=4, B3 =8, B4=16, B5=32, B6 =64…

Page 12: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 12

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Binary Integers 4

Here are the first few binary numbers:

…101110 means:

(0*20)+(1*21)+(1*22)+(1*23)+(0*24)+(1*25) = (0*1)+(1*2)+(1*4)+(1*8)+(0*16)+(1*32) = 4610

00002 = 010 01002 = 410 10002 = 810 11002 = 1210 100002 = 1610

00012 = 110 01012 = 510 10012 = 910 11012 = 1310 100012 = 1710

00102 = 210 01102 = 610 10102 = 1010 11102 = 1410 100102 = 1810

00112 = 310 01112 = 710 10112 = 1110 11112 = 1510 100112 = 1910

Page 13: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 13

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Binary Conversion Example

Convert binary number 10111 to decimal:

10111

1 * 1 1 * 21 * 4

=1=2

=40 * 8 =0

1 * 16 =16

=23

Page 14: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 14

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Convert binary number to decimal: 10111001

1 * 1

0 * 2

0 * 4

=1

=0

=0

1 * 8 =8

1 * 16 =16

=185

1 * 32 =32

0 * 64 =01 * 128 =128

Page 15: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 15

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Octal Integers 1Just as the each digit (position) in decimal integer is represented by the power of 10, in binary integer each digit represents power of 2, in octal numbers each digit is represented by the power of 8 (Base = 8).

Digits range: 0 -> (Base - 1)Number of values represented by a single digit: Base

Digits range: 0 -> 7 (0,1, 2, 3, 4, 5, 6, 7)Number of values represented by a single digit: 8

Page 16: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 16

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Octal Integers 2

In the decimal number the digits could be 0,1,2,3,4,5,6,7,8,9. (0 -> Base-1), in binary 0,1 (Base-1), so as you can suspect in octal numbers the digits would be 0,1,2,3,4,5,6,7 (0 -> Base-1).

The single decimal number can represent 10 values, the single binary number can represent only 2 values, and single octal number can represent 8 values.

Page 17: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 17

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Octal Integers 3

In octal integers Base = 8.

Please recall the formula:

(D0*B0)+(D1*B1)+(D2*B2)+(D3*B3)+…(Dn*Bn)

Lets look at the octal number 4153

D0=3, D1=5, D2=1, D3=4

B0=1, B1=8, B2=64, B3 =512, B4=4096…

Page 18: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 18

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Octal Integers 4

Here are the first few octal numbers:

…4153 means:

(3*80)+(5*81)+(1*82)+(4*83) = (3*1)+(5*8)+(1*64)+(4*512) = 215510

00008 = 010 00048 = 410 00108 = 810 00148 = 1210 00208 = 1610

00018 = 110 00058 = 510 00118 = 910 00158 = 1310 00218 = 1710

00028 = 210 00068 = 610 00128 = 1010 00168 = 1410 00228 = 1810

00038 = 310 00078 = 710 00138 = 1110 00178 = 1510 00238 = 1910

Page 19: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 19

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Hexadecimal (Hex) Integers 1Just as the each digit (position) in decimal integer is represented by the power of 10, in binary integer - power of 2, in octal numbers - power of 8, and in hex integers – power of 16 (Base = 16).

Digits range: 0 -> (Base - 1)Number of values represented by a single digit: Base

Digits range: 0 -> 15 (0,1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)Number of values represented by a single digit: 16

Page 20: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 20

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Hex Integers 2

In the decimal number the digits could be 0,1,2,3,4,5,6,7,8,9. (0 -> Base-1), in binary 0,1 (Base-1), in octal 0,1,2,3,4,5,6,7. (0 -> Base-1). In hex numbers the digits would be 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F (0 -> Base-1). The letters A through F represent the decimal numbers 10 to 15.

The single decimal number can represent 10 values, the single binary number can represent only 2 values, the single octal number can represent 8 values, and the single hex number can represent 16 values.

Page 21: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 21

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Hex Integers 3

In Hex integers Base = 16.

Please recall the formula:

(D0*B0)+(D1*B1)+(D2*B2)+(D3*B3)+…(Dn*Bn)

Lets look at the octal number A59C

D0=C, D1=9, D2=5, D3=A

B0=1, B1=16, B2=256, B3 =4096, B4=65536…

Page 22: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 22

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Hex Integers 4

Here are the first few hex numbers:

…A59C means:

(12*160)+(9*161)+(5*162)+(A*163) = (12*1)+(9*16)+(5*256)+(10*4096) = 4239610

00016 = 010 00416 = 410 00816 = 810 00C16 = 1210 01016 = 1610

00116 = 110 00516 = 510 00916 = 910 00D16 = 1310 01116 = 1710

00216 = 210 00616 = 610 00A16 = 1010 00E16 = 1410 01216 = 1810

00316 = 310 00716 = 710 00B16 = 1110 00F16 = 1510 01316 = 1910

Page 23: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 23

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Relationship between Binary and Octal Numbers

10110102 = 9010

Converting to Octal:

Binary: 001 011 010 = 9010

Octal: 1 3 2 = 9010 each octal digit is 3 bits

Page 24: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 24

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Relationship between Binary and Hex Numbers

10110102 = 9010

Converting to Hex:

Binary: 0101 1010 = 9010

Hex: 5 A = 9010 each hex digit is 4 bits

Page 25: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 25

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Relationship between Binary, Octal and Hex Numbers 1

1111011011100101101010110102

Converting to Octal:

111 101 101 110 010 110 101 011 010 7 5 5 6 2 6 5 3 2

Converting to Hex:

0111 1011 0111 0010 1101 0101 1010 7 B 7 2 D 5 A

Page 26: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 26

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

Relationship between Binary, Octal and Hex Numbers 2

Decimal Binary Octal (3 binary digits) Hex (4 binary digits)

0 00000 0 0

1 00001 1 1

2 00010 2 2

3 00011 3 3

4 00100 4 4

5 00101 5 5

6 00110 6 6

7 00111 7 7

8 01000 10 8

9 01001 11 9

10 01010 12 A

11 01011 13 B

12 01100 14 C

13 01101 15 D

14 01110 16 E

15 01111 17 F

16 10000 20 10

17 10001 21 11

18 10010 22 12

19 10011 23 (10 + 011) 13 (1 + 0011)

Page 27: 1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar

04/11/23 Slide # 27

Binary, Octal and Hex NumbersCopyright Thaddeus Konar

"nobody wants to be a 0 but everybody wants to be a 1"

Laurie Anderson - Home of the Brave