Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab #1 Follow-Up Unix Binary / Hexadecimal Python.

Similar presentations


Presentation on theme: "Lab #1 Follow-Up Unix Binary / Hexadecimal Python."— Presentation transcript:

1 Lab #1 Follow-Up Unix Binary / Hexadecimal Python

2 Lab #1 Follow-Up Unix Binary / Hexadecimal Python

3

4 Media Access Control (MAC) address

5 B4-D8-A9-00-04-07

6

7

8

9 DecimalHex(adecimal)0123456789 10A 11B 12C 13D 14E 15F

10 B 4 DecimalHex(adecimal)0123456789 10A 11B 12C 13D 14E 15F

11 B 4 DecimalHex(adecimal)0123456789 10A 11B 12C 13D 14E 15F 11×16 + 4×1

12 B 4 DecimalHex(adecimal)0123456789 10A 11B 12C 13D 14E 15F 11×16 1 + 4×16 0

13 B 4 DecimalHex(adecimal)0123456789 10A 11B 12C 13D 14E 15F 11×16 + 4×1

14 B 4 DecimalHex(adecimal)0123456789 10A 11B 12C 13D 14E 15F 11×16 + 4×1 176 + 4

15 B 4 DecimalHex(adecimal)0123456789 10A 11B 12C 13D 14E 15F 11×16 + 4×1 176 + 4 180

16 All modern numbering systems work this way B 4 11×16 1 + 4×16 0 11×16 + 4×1 176 + 4 180 1×10 2 + 8×10 1 + 0×10 0 100 + 80 + 0 1×100 + 8×10 + 0×1 180

17 Why Base 16?

18 DecimalHexBinary 000 111 2210 3311 44100 55101 66110 77111 881000 991001 10A1010 11B1011 12C1100 13D1101 14E1110 15F1111

19 Why Base 16? DecimalHexBinary 0000000 0110001 0220010 0330011 0440100 0550101 0660110 0770111 0881000 0991001 10A1010 11B1011 12C1100 13D1101 14E1110 15F1111

20 B 4 Eight Bits = One Byte DecimalHexBinary 000000 110001 220010 330011 440100 550101 660110 770111 881000 991001 10A1010 11B1011 12C1100 13D1101 14E1110 15F1111 1011 0100

21 Why Base Two?

22

23 ENIAC (1946)

24 1940s Faster, Cheaper, Smaller 1950s 1960s Today Vacuum tube RelayTransistor Integrated Circuits

25

26 ● To convert from binary to decimal Start from right Multiply 0,1 by powers of two (1, 2, 4, 8, …) Sum of these products is decimal equivalent ● E.g., 1 1 0 1 2 = ??? 10 Binary-to-Decimal Conversion

27 ● To convert from binary to decimal Start from right Multiply 0,1 by powers of two (1, 2, 4, 8, …) Sum of these products is decimal equivalent ● E.g., 1 1 0 1 2 = ??? 10 1 * 2 0 = 1 Binary-to-Decimal Conversion

28 ● To convert from binary to decimal Start from right Multiply 0,1 by powers of two (1, 2, 4, 8, …) Sum of these products is decimal equivalent ● E.g., 1 1 0 1 2 = ??? 10 1 * 2 0 = 1 +0 * 2 1 = 0

29 Binary-to-Decimal Conversion ● To convert from binary to decimal Start from right Multiply 0,1 by powers of two (1, 2, 4, 8, …) Sum of these products is decimal equivalent ● E.g., 1 1 0 1 2 = ??? 10 1 * 2 0 = 1 +0 * 2 1 = 0 +1 * 2 2 = 4

30 Binary-to-Decimal Conversion ● To convert from binary to decimal Start from right Multiply 0,1 by powers of two (1, 2, 4, 8, …) Sum of these products is decimal equivalent ● E.g., 1 1 0 1 2 = ??? 10 1 * 2 0 = 1 +0 * 2 1 = 0 +1 * 2 2 = 4 +1 * 2 3 = 8

31 Binary-to-Decimal Conversion ● To convert from binary to decimal Start from right Multiply 0,1 by powers of two (1, 2, 4, 8, …) Sum of these products is decimal equivalent ● E.g., 1 1 0 1 2 = 13 10 1 * 2 0 = 1 +0 * 2 1 = 0 +1 * 2 2 = 4 +1 * 2 3 = 8 ____________ 13

32 13r 2 = 1 13 ÷ 2 = 6 6r 2 = 0 6 ÷ 2 = 3 3r 2 = 1 3 ÷ 2 = 1 1r 2 = 1 1 ÷ 2 = 0 ___________ 1 1 0 1 Decimal-to-Binary Conversion To convert from decimal to binary 1.Take remainder of decimal number / 2 2.Write down remainder right-to-left 3.If decimal number is zero, we’re done 4.Divide decimal number by 2 5.Go to step 1.

33 Fractions 3.25 10 = ???? 2

34 Fractions 3. 2 5 3×10 0 + 2×10 -1 + 5×10 -2

35 Fractions 3. 2 5 10 = 3×10 0 + 2×10 -1 + 5×10 -2 1 1. 0 1 2 1×2 1 + 1×2 0 + 0×2 -1 + 1×2 -2

36 Problem! 3.2 10 = ???? 2

37 Google patriot missile failure for a real-world example

38 What about text? ASCII: One byte per character

39 What about text? Unicode: (Up to) two bytes per character

40 Numbers or text? Each application (MS Word, Excel) expects either (ASCII) text or (“raw binary”) numbers Try opening a an Excel spreadsheet in WordPad!


Download ppt "Lab #1 Follow-Up Unix Binary / Hexadecimal Python."

Similar presentations


Ads by Google