review binary –each digit place is a power of 2 –any two state phenomenon can encode a binary...
Post on 20-Dec-2015
216 views
TRANSCRIPT
![Page 1: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/1.jpg)
Review
• Binary– Each digit place is a power of 2– Any two state phenomenon can encode a binary
number– The number of bits (digits) required directly
relates to the amount of physical resource required
– Bit, Byte, 1K, 1Meg
![Page 2: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/2.jpg)
Review
• Integers – Simple whole numbers
– How many bits required to contain an integer• The power of 2 just larger than that integer
• Floating point– Numbers with decimal points
– Numbers with exponents
– Can represent very large and very small numbers
![Page 3: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/3.jpg)
Review
• Numeric expressions (+ - * /)1+2
3*4 + 7
6.2/(4.2-2.2)
• Boolean (true, false) (<, >, <=, >=, ==, !=)1 > 2
(3*5) <= 17
![Page 4: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/4.jpg)
Review
• Characters– Every character corresponds to a unique
number– Sorting order– ASCII - encodes all American English
characters (1 byte)– UNICODE encodes all commercially used
characters in the world (2 bytes)
![Page 5: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/5.jpg)
Programs
• Variables
• Assignment
• Sequences of instructions
![Page 6: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/6.jpg)
Variables
• A named place to store a value
• AssignmentGeorge = 32;
Size = 17;
Weight = 120;
George 32Size 17Weight 120
![Page 7: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/7.jpg)
Program
• A sequence of things to do
A = 75;
B = A+13;
A = A-B+3;
C = A/2 + 1;
![Page 8: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/8.jpg)
Program
• A sequence of things to do
A = 75;
B = A+13;
A = A-B+3;
C = A/2 + 1;
A 75B ?C ?
![Page 9: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/9.jpg)
Program
• A sequence of things to do
A = 75;
B = A+13;
A = A-B+3;
C = A/2 + 1;
A 75B 88C ?
A + 13
75 + 13 = 88
![Page 10: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/10.jpg)
Program
• A sequence of things to do
A = 75;
B = A+13;
A = A-B+3;
C = A/2 + 1;
A -10B 88C ?
A-B+3
75 - 88 + 3 = -10
![Page 11: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/11.jpg)
Program
• A sequence of things to do
A = 75;
B = A+13;
A = A-B+3;
C = A/2 + 1;
A -10B 88C -4
A / 2 + 1
-10 / 2 + 1 = -4
![Page 12: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/12.jpg)
Program Quiz
• Do each in sequence
Fred = 2*7;
Jane = 16;
Fred = Jane - Fred;
Jane = Fred/2;
Fred ?Jane ?
![Page 13: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/13.jpg)
Program Quiz
• Do each in sequence
Fred = 2*7;
Jane = 16;
Fred = Jane - Fred;
Jane = Fred/2;
Fred 14Jane ?
![Page 14: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/14.jpg)
Program Quiz
• Do each in sequence
Fred = 2*7;
Jane = 16;
Fred = Jane - Fred;
Jane = Fred/2;
Fred 14Jane 16
![Page 15: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/15.jpg)
Program Quiz
• Do each in sequence
Fred = 2*7;
Jane = 16;
Fred = Jane - Fred;
Jane = Fred/2;
Fred 14Jane 16
Jane - Fred16 - 142
![Page 16: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/16.jpg)
Program Quiz
• Do each in sequence
Fred = 2*7;
Jane = 16;
Fred = Jane - Fred;
Jane = Fred/2;
Fred 2Jane 16
Jane - Fred16 - 142
![Page 17: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/17.jpg)
Program Quiz
• Do each in sequence
Fred = 2*7;
Jane = 16;
Fred = Jane - Fred;
Jane = Fred/2;
Fred 2Jane 1
![Page 18: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/18.jpg)
Arrays
• Access by Index
0 ?1 ?2 ?3 ?4 ?
A
0 ?1 ?2 ?
B
![Page 19: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/19.jpg)
Arrays
• Access by Index
A[0] = 7;
B[1] = 4;
B[2] = A[0]+1;
A[1] = B[2]/2;
A[3] = 7-B[1];
0 ?1 ?2 ?3 ?4 ?
A
0 ?1 ?2 ?
B
![Page 20: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/20.jpg)
Arrays
• Access by Index
A[0] = 7;
B[1] = 4;
B[2] = A[0]+1;
A[1] = B[2]/2;
A[3] = 7-B[1];
0 71 ?2 ?3 ?4 ?
A
0 ?1 ?2 ?
B
![Page 21: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/21.jpg)
Arrays
• Access by Index
A[0] = 7;
B[1] = 4;
B[2] = A[0]+1;
A[1] = B[2]/2;
A[3] = 7-B[1];
0 71 ?2 ?3 ?4 ?
A
0 ?1 42 ?
B
![Page 22: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/22.jpg)
Arrays
• Access by Index
A[0] = 7;
B[1] = 4;
B[2] = A[0]+1;
A[1] = B[2]/2;
A[3] = 7-B[1];
0 71 ?2 ?3 ?4 ?
A
0 ?1 42 8
B
![Page 23: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/23.jpg)
Arrays
• Access by Index
A[0] = 7;
B[1] = 4;
B[2] = A[0]+1;
A[1] = B[2]/2;
A[3] = 7-B[1];
0 71 42 ?3 ?4 ?
A
0 ?1 42 8
B
![Page 24: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/24.jpg)
Arrays
• Access by Index
A[0] = 7;
B[1] = 4;
B[2] = A[0]+1;
A[1] = B[2]/2;
A[3] = 7-B[1];
0 71 42 ?3 34 ?
A
0 ?1 42 8
B
![Page 25: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/25.jpg)
Strings
• An array of Characters
A=“Lloyd”;
B= “Big”;
B[2] = A[0]+1;
A B0 76 L1 108 l2 111 o3 121 y4 100 d
0 ?1 ?2 ?
![Page 26: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/26.jpg)
Strings
• An array of Characters
A=“Lloyd”;
B= “Big”;
B[2] = A[0]+1;
A B0 76 L1 108 l2 111 o3 121 y4 100 d
0 66 B1 105 i2 103 g
![Page 27: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/27.jpg)
Strings
• An array of Characters
A=“Lloyd”;
B= “Big”;
B[2] = A[0]+1;
A B0 76 L1 108 l2 111 o3 121 y4 100 d
0 66 B1 105 i2 77 M
![Page 28: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/28.jpg)
Strings
• How do you put “ in a string?
• Special characters preceded by \
A=“Lloyd”;
B= “Big”;
B[2] = A[0]+1;
B = “\”P\\”
A B0 76 L1 108 l2 111 o3 121 y4 100 d
0 34 "1 80 P2 92 \
![Page 29: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/29.jpg)
Sound• Each time samples the volume (amplitude)• Sound = array of volume values
0 1 2 3 4 5 6 7 8 9 10-10 -5 10 20 10 -7 -15 -20 -12 4 8
![Page 30: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/30.jpg)
2D-Arrays
Rows
Columns
[Rows-1,Columns-1]
[0,0]
# of elements = Rows * Columns
5
10
[4,9]5 * 10 = 50
![Page 31: Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates](https://reader035.vdocument.in/reader035/viewer/2022062516/56649d4b5503460f94a28e9e/html5/thumbnails/31.jpg)
Images - 2D array of values
• Image [x,y]