Presentation is loading. Please wait.

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

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

Lab #1 Follow-Up Unix Binary / Hexadecimal Python

Lab #1 Follow-Up Unix Binary / Hexadecimal Python

Media Access Control (MAC) address

B4-D8-A9-00-04-07

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

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

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

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

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

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

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

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

Why Base 16?

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

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

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

Why Base Two?

ENIAC (1946)

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

● 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

● 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

● 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

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

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

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

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.

Fractions 3.25 10 = ???? 2

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

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

Problem! 3.2 10 = ???? 2

Google patriot missile failure for a real-world example

What about text? ASCII: One byte per character

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

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