0% found this document useful (0 votes)
49 views

Data Types, Variables, and Constants

This document discusses representing data using bits and bytes in computers. It explains that computers use binary represented by 1s and 0s to represent anything, making them powerful. It then gives an example of using coin flips to decide who would open the first Christmas present, where one solution used a tournament style with 3 coin flips while a computer scientist solution used 2 coin flips and binary representation to determine the winner. The document also presents the formula that b bits are needed to represent n distinct things.

Uploaded by

Araxhiel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Data Types, Variables, and Constants

This document discusses representing data using bits and bytes in computers. It explains that computers use binary represented by 1s and 0s to represent anything, making them powerful. It then gives an example of using coin flips to decide who would open the first Christmas present, where one solution used a tournament style with 3 coin flips while a computer scientist solution used 2 coin flips and binary representation to determine the winner. The document also presents the formula that b bits are needed to represent n distinct things.

Uploaded by

Araxhiel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Module 3

Data Types, Variables, and


Constants

Lecture
Bits and Bytes

Module 3 Learning Objectives
Why do we care?
1s and 0s to represent
anything, so
computers are
powerful
But how many bits do
we need to represent
something?

Christmas morning, my family was trying to decide who
of the 4 of us (one of my sons wasnt there yet) would
get to open the first present using coin flips. My son
(another computer scientist) and I came up with one
answer while the non-computer scientists came up with
another answer.

Treat it like a
tournament
3 flips
Flip 1: Person A vs
Person B
Flip 2: Person C vs
Person D
Flip 3: Winner of Flip 1
vs Winner of Flip 2
Use the power of
binary!
2 flips
0 for tails, 1 for heads
00: Person A wins
01: Person B wins
10: Person C wins
11: Person D wins

n = 2
b

We need b bits to
represent n distinct
things

Recap
n = 2b
b = log2n
Next Time
Ones and Zeros

You might also like