Data and Storage
Today, we'll learn how computers store information ("data"). We'll also learn how we can manipulate data in code.
Decimal | 0 |
Binary | 0 |
0101 (5) + 0111 (7)
0101 (5) + 1011 (11)
0111 (7) + 0011 (3)
1.875*2^2
Word Problems | Solution |
---|---|
Alice has 600 MB of data. Bob has 700 MB of data. Will it all fit on Alice's 2 GB thumb drive? |
Yes it fits: 600 MB + 700 MB is 1300 MB. 1300 MB is 1.3 GB, so it will fit on the 2 GB drive no problem. Equivalently we could say that the 2 GB drive has space for 2000 MB, so the 1300 MB fits.
|
Alice has 100 small images, each of which is 500 KB. How much space do they take up overall in MB? |
100 times 500 KB is 50000 KB, which is 50 MB.
|
Your ghost hunting group is recording the sound inside a haunted Stanford classroom for 20 hours as MP3 audio files. About how much data will that be, expressed in GB? |
MP3 audio takes up about 1 MB per minute. 20 hours, 60 minutes/hour, 20 * 60 yields 1200 minutes. So that's about 1200 MB, which is 1.2 GB.
|
Character | ASCII value | ASCII (binary) | Huffman (binary) |
---|---|---|---|
' ' |
32 |
00100000 |
10 |
'a' |
97 |
01100001 |
0001 |
'b' |
98 |
01100010 |
0111010 |
'c' |
99 |
01100011 |
001100 |
'e' |
101 |
01100101 |
1100 |
'z' |
122 |
01111010 |
00100011010 |
Source: Marty Stepp
Scheme | Lossless vs. Lossy? | Medium | Notes |
---|---|---|---|
MP3 | Lossy | Audio | 10x less space, but still sounds good |
JPEG | Lossy | Images | Free and open source; very widely used and supported |
GIF and PNG | Lossless | Images | PNG is a little bit better;mostly used for non-photographs |
The image on the right has been extremely compressed, taking up about 29% of the space as the image on the left.
myName
) without spaces and value ("Ashley Taylor"
)
=
) sign
prompt
+ - * /
=
to store the result
parseInt("4")
gives you the number 4