View
19
Download
0
Category
Tags:
Preview:
DESCRIPTION
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. B4 -D8-A9-00-04-07. B4 -D8-A9-00-04-07. B4 -D8-A9-00-04-07. Decimal Hex( adecimal ) 00 1 1 2 2 3 3 4 4 - PowerPoint PPT Presentation
Citation preview
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
B4-D8-A9-00-04-07
B4-D8-A9-00-04-07
B4-D8-A9-00-04-07
Decimal Hex(adecimal)
0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F
B 4
Decimal Hex(adecimal)
0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F
B 4
Decimal Hex(adecimal)
0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F
11×16 + 4×1
B 4
Decimal Hex(adecimal)
0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F
11×161 + 4×160
B 4
Decimal Hex(adecimal)
0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F
11×16 + 4×1
B 4
Decimal Hex(adecimal)
0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F
11×16 + 4×1176 + 4
B 4
Decimal Hex(adecimal)
0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F
11×16 + 4×1176 + 4
180
All modern numbering systems work this way
B 411×161 + 4×160
11×16 + 4×1176 + 4
180
1 8 01×102 + 8×101 + 0×100
100 + 80 + 0
1×100 + 8×10 + 0×1
180
Why Base 16?
Why Base 16?Decimal Hex Binary
0 0 01 1 12 2 103 3 114 4 1005 5 1016 6 1107 7 1118 8 10009 9 100110 A 101011 B 101112 C 110013 D 110114 E 111015 F 1111
Why Base 16?Decimal Hex Binary
00 0 000001 1 000102 2 001003 3 001104 4 010005 5 010106 6 011007 7 011108 8 100009 9 100110 A 101011 B 101112 C 110013 D 110114 E 111015 F 1111
B 4
Eight Bits = One ByteDecimal Hex Binary
0 0 00001 1 00012 2 00103 3 00114 4 01005 5 01016 6 01107 7 01118 8 10009 9 100110 A 101011 B 101112 C 110013 D 110114 E 111015 F 1111
1011 0100
Why Base Two?
Why Base Two?
ENIAC (1946)
1940s
Faster, Cheaper, Smaller
1950s
1960s Today
Vacuum tubeRelay Transistor
IntegratedCircuits
● 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 = ??? 101 * 20 =
1
Binary-to-Decimal Conversion
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 = ??? 101 * 20 =
1+ 0 * 21 = 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 = ??? 101 * 20 =
1+ 0 * 21 = 0+ 1 * 22 = 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 = ??? 101 * 20 =
1+ 0 * 21 = 0+ 1 * 22 = 4+ 1 * 23 = 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 101 * 20 =
1+ 0 * 21 = 0+ 1 * 22 = 4+ 1 * 23 = 8
____________
13
13 r 2 = 1
13 ÷ 2 = 6
6 r 2 = 0
6 ÷ 2 = 3
3 r 2 = 1
3 ÷ 2 = 1
1 r 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.2510 = ????2
Fractions
3. 2 5 3×100 + 2×10-1 + 5×10-2
Fractions
3. 2 5 10 =
3×100 + 2×10-1 + 5×10-2
1 1. 0 1 2
1×21 + 1×20 + 0×2-1 + 1×2-2
Problem!
3.210 = ????2
Google patriot missile failure for areal-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!
Recommended