APCS – Unit 1 – Lesson 6 – Data Storage: Bits and Bytes

1. What is a bit?

As we have already known, computers stores everything in 0s and 1s. A bit is a binary digit, and it can only have the value 0 or 1. It is the smallest building block of the computer storage.

Anything with two separate states can store 1 bit: true and false, on and off, north and south, etc.

2. What is a byte?

A bit is too small to be used to store most information. Therefore, 8 bits are grouped together to make 1 byte.

1 byte = 8 bits

Here are several examples of bytes, they are all binary numbers that are exactly 8 digits (bits) long:

11010110

10011001

11110000

10101010

10011111

One byte can store one character (or char), e.g.  ‘A’, ‘&’, ‘b’, ‘%’. Byte is the unit of information storage. All computer storage are measured in bytes.

3. How many different combinations are possible in a byte?

Let’s use the basic approach:

For 1 bit, there are 2 combinations: 1 and 0.

For 2 bits, there are 4 combinations: 00, 01, 10, 11

For 3 bits, there are 8 combinations: 000, 001, 010, 011, 100, 110, 101, 111

For 4 bits, there are 16 combinations: 0000, 0001, 0011, 0111, 0010, 0100, 0101, 0110, 1000, 1100, 1110, 1111, 1010, 1011, 1101, 1001

… …

When a bit is added, the number of combinations doubles!  Therefore, for 8 bits, there are 2^8 = 256 different combinations!

Of course, if you have learned combinatorics and still remember the rules, you have figured this out already!

4. Kilobyte, Megabyte, Gigabyte, Terabyte

5. Bytes and Characters – ASCII Code

ASCII is an encoding representing each typed character by a number. Each number is stored in one byte (so the number is in 0..255):

  • A is 65
  • B is 66
  • a is 96
  • space is 32
  • “Unicode” is an encoding for mandarin, greek, arabic, etc. languages, typically 2-bytes per “character”

List of References:

https://web.stanford.edu/class/cs101/bits-bytes.html

Class 2.03: Inside the Computer