credits: cs unplugged -
TRANSCRIPT
Credits: CS Unplugged - http://csunplugged.org
How is data stored?
Data is stored on a computer in the form of bits
What is a bit? A unit of information expressed as either a 0 or 1 in
binary notation
Everything on a computer (music, photos, text, movies, spreadsheets, etc) is represented and stored in binary form (as a combination of 0’s and 1’s)
Activity
Take your deck of cards and lay them out exactly as shown in the figure below
Binary representation - Activity
Now flip the cards so exactly 5 dots show—keep your cards in the same order!
Try more examples
Find out how to make the numbers 3, 12, 19.
Is there more than one way to make any number?
What is the biggest number you can make?
What is the smallest?
Is there any number you can’t make between the smallest and biggest numbers?
Binary system
The binary system uses zero and one to represent whether a card is face-up or not. 0 shows that a card is hidden, and 1 means that it is face-up and you can see the dots.
For example, 01001 = 9
Working with binary representations
Can you work out what 10101 is?
Can you work out what 11111 is?
What day of the month were you born? Write it in binary
Find out what your neighbor’s birthday is and represent it in binary
Counting beyond 31
Look at the binary cards again. If you were going to make the next card in the sequence, how many dots would it have? If you look at the sequence carefully, you can find a very
interesting relationship: 1, 2, 4, 8, 16, …
What about the next card after that?
What is the rule that you are following to make your new cards?
Counting beyond 31
As you can see, only a few cards are needed to count up to very big numbers.
6 cards can count up to 64
10 cards can count up to 1024
Bits, Bytes and so on
One bit on its own can’t represent much, so they are usually grouped together in groups of eight, which can represent numbers from 0 to 255.
A group of eight bits is called a byte.
A thousand bytes form a Kilo-byte (Kb)
A thousand Kilobytes form a Mega-byte (Mb)
A thousand Megabytes form a Giga-byte (Gb) and so on (Terabyte, Petabyte, … )
Binary system
The binary system uses powers of 2 to represent the numbers
2 = 10 = 1*21 + 0*20
3 = 11 = 1*21 + 1*20
4 = 100 = 1*22 + 0*21 + 0*20
7 = 111 = 1*22 + 1*21 + 1*20
A Byte
A byte can store 8-bits of information
Has a range from 0-255
Any character (A, 1, $, ; …) can be stored in a byte
An integer can be stored in 2-bytes Can represent numbers from 0-65535. Alternately, you
can represent numbers between -32768 to 32767
Floating point
As you have seen, integer data types (int) are used to store integer values (3, 6, 121, 5423, etc.)
To store decimal values, you use the floating point data type (float)
float e = 2.718;
float area = 22.14;
Any other examples for floating point values?