binary values
DESCRIPTION
Binary Values. Chapter 2. Why Binary?. Electrical devices are most reliable when they are built with 2 states that are hard to confuse : • gate open / gate closed. Why Binary?. Electrical devices are most reliable when they are built with 2 states that are hard to confuse : - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/1.jpg)
Binary Values
Chapter 2
![Page 2: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/2.jpg)
Why Binary?
Electrical devices are most reliable when they are built with 2 states that are hard to confuse:
• gate open / gate closed
![Page 3: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/3.jpg)
Why Binary?
Electrical devices are most reliable when they are built with 2 states that are hard to confuse:
• gate open / gate closed
• full on / full off
• fully charged / fully discharged
• charged positively / charged negatively
• magnetized / nonmagnetized
• magnetized clockwise / magnetized ccw
These states are separated by a huge energy barrier.
![Page 4: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/4.jpg)
Punch Cards
hole No hole
![Page 5: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/5.jpg)
Jacquard Loom
Invented in 1801
![Page 6: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/6.jpg)
Jacquard Loom
Invented in 1801
![Page 7: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/7.jpg)
Why Weaving is Binary
![Page 8: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/8.jpg)
Holes Were Binary But Encodings Were Not
![Page 9: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/9.jpg)
Holes Were Binary But Encodings Were Not
11111111111101111111111111111110
![Page 10: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/10.jpg)
Everyday Binary Things
Examples:
![Page 11: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/11.jpg)
Everyday Binary Things
Examples:
• Light bulb on/off
• Door locked/unlocked
• Garage door up/down
• Refrigerator door open/closed
• A/C on/off
• Dishes dirty/clean
• Alarm set/unset
![Page 12: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/12.jpg)
Binary (Boolean) Logic
If: customer’s account is at least five years old, and
customer has made no late payments this yearor
customer’s late payments have been forgiven, and
customer’s current credit score is at least 700
Then: Approve request for limit increase.
![Page 13: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/13.jpg)
Exponential Notation
• 42 = 4 * 4 =
• 43 = 4 * 4 * 4 =
• 103 =
• 1011 = 100,000,000,000
![Page 14: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/14.jpg)
Powers of Two
![Page 15: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/15.jpg)
Powers of Two
![Page 16: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/16.jpg)
Powers of Two
1 2 3 4 5 6 7 8 9 10 11 12 13 140
2000
4000
6000
8000
10000
12000
14000
16000
18000
Series1
0 11 22 43 84 165 326 647 1288 2569 512
10 102411 204812 409613 819214 16384
![Page 17: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/17.jpg)
Positional Notation
2473 = 2 * 1000 (103) = 2000 + 4 * 100 (102) = 400 + 7 * 10 (101) = 70 + 3 * 1 (100) = 3
2473
= 2 * 103 + 4 * 102 + 7 * 101 + 3 * 100
Base 10
![Page 18: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/18.jpg)
Base 8 (Octal)
93 = 1 * 64 (82) = 64 29 + 3 * 8 (81) = 24 5 + 5 * 1 (80) = 5 0
93
93 = 1358
remainder512
![Page 19: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/19.jpg)
Base 3 (Ternary)
95 = 1 * 81 (34) = 81 14 + 0 * 27 (33) = 0 14
+ 1 * 9 (32) = 9 5 + 1 * 3 (31) = 3 2 + 2 * 1 (100) = 0 0
93
93 = 101123
remainder
![Page 20: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/20.jpg)
Base 2 (Binary)
93 = 1 * 64 (26) = 64 29 + 0 * 32 (25) = 0 29 + 1 * 16 (24) = 16 13 + 1 * 8 (23) = 8 5
+ 1 * 4 (22) = 4 1 + 0 * 2 (31) = 0 1 + 1 * 1 (100) = 1 0
93
93 = 10111012
remainder128
![Page 21: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/21.jpg)
Counting in Binary
http://www.youtube.com/watch?v=zELAfmp3fXY
![Page 22: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/22.jpg)
A Conversion Algorithm
def dec_to_bin(n): answer = "" while n != 0: remainder = n % 2 n = n //2 answer = str(remainder) + answer return(answer)
![Page 23: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/23.jpg)
Running the Tracing Algorithm
Try:
• 13• 64• 1234• 345731
![Page 24: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/24.jpg)
An Easier Way to Do it by Hand 1 2 4 8 16 32 64 128 256 512 1,024 2,048 4,096 8,19216,384
![Page 25: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/25.jpg)
The Powers of 2 1 2 4 8 16 32 64 128 256 512 1,024 2,048 4,096 8,19216,384
Now you try the examples on the handout.
![Page 26: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/26.jpg)
My Android Phone
![Page 27: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/27.jpg)
Naming the Quantities
See Dale and Lewis, page 124.
103 = 1000 210 = 1024
![Page 28: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/28.jpg)
How Many Bits Does It Take?
• To encode 12 values:
• To encode 52 values:
• To encode 3 values:
![Page 29: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/29.jpg)
A Famous 3-Value Example
![Page 30: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/30.jpg)
A Famous 3-Value Example
One, if by land, and two, if by sea;And I on the opposite shore will be,
![Page 31: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/31.jpg)
Braille
![Page 32: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/32.jpg)
Braille
With six bits, how many symbols can be encoded?
![Page 33: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/33.jpg)
Braille Escape Sequences
Indicates that the next symbol is capitalized.
![Page 34: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/34.jpg)
Binary Strings Can Get Really Long
111111110011110110010110
![Page 35: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/35.jpg)
Binary Strings Can Get Really Long
111111110011110110010110
![Page 36: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/36.jpg)
Base 16 (Hexadecimal)
52 = 110100 already hard for us to read
![Page 37: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/37.jpg)
Base 16 (Hexadecimal)
52 = 110100 already hard for us to read
= 11 0100
3 4
![Page 38: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/38.jpg)
Base 16 (Hexadecimal)
52 = 110100
![Page 39: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/39.jpg)
Base 16 (Hexadecimal)
52 = 110100
= 3 * 16 (161) = 48 4 + 4 * 1 (160) = 4 0
52
52 = 3416
256
![Page 40: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/40.jpg)
Base 16 (Hexadecimal)
2337 = 9 * 256 (162) = 2304 33 + 2 * 16 (161) = 32 1 + 1 * 1 (160) = 1 0
2337
2337 = 92116
2337 = 1001 0010 00012
4096
![Page 41: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/41.jpg)
Base 16 (Hexadecimal)
We need more digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
31 = 1 * 16 (161) = 16 15 + ? * 1 (160) = 15 0
31
31 = 3 16?
![Page 42: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/42.jpg)
Base 16 (Hexadecimal)
We need more digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
31 = 1 * 16 (161) = 16 15 + ? * 1 (160) = 15 0
31
31 = 3 16?
31 = 1F16
![Page 43: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/43.jpg)
Base 16 (Hexadecimal)
F F 3 D 9 6
1111 1111 0011 1101 1001 0110
![Page 44: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/44.jpg)
A Very Visible Use of Hex
http://easycalculation.com/color-coder.php
http://lectureonline.cl.msu.edu/~mmp/applist/RGBColor/c.htm
![Page 45: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/45.jpg)
Binary, Octal, Hex
16 = 24
So one hex digit corresponds to four binary ones.
Binary to hex: 101 1111 95
5 F
![Page 46: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/46.jpg)
Binary, Octal, Hex
16 = 24
So one hex digit corresponds to four binary ones.
Binary to hex: 101 1111 95
5 F
Binary to hex: 101 1110 1111 5 E F
![Page 47: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/47.jpg)
Binary, Octal, Hex
16 = 24
So one hex digit corresponds to four binary ones.
Binary to hex: 1011111 95
5 F
Binary to hex: 0101 1110 1111 1519 5 E F
byte
![Page 48: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/48.jpg)
Binary, Octal, Hex
16 = 24
So one hex digit corresponds to four binary ones.
Hex to decimal: 5 F
0101 1111 then to decimal: 95
![Page 49: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/49.jpg)
Binary Arithmetic
Addition:
11010 + 1001
![Page 50: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/50.jpg)
Binary Arithmetic
Multiplication:
11010 * 11
![Page 51: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/51.jpg)
Binary Arithmetic
Multiplication by 2:
11010 * 10
![Page 52: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/52.jpg)
Binary Arithmetic
Multiplication by 2:
11010 * 10
Division by 2:
11010 // 10
![Page 53: Binary Values](https://reader035.vdocument.in/reader035/viewer/2022062410/56816460550346895dd63a4f/html5/thumbnails/53.jpg)
Computer Humor
http://www.youtube.com/watch?v=WGWmh1fK87A