Units of data

Bits and Binary

Computers 💻 use binary

  • Binary is a number system that is base 2.
    • Typically these values are either 0 (off) or 1 (on)
  • Bit stands for Binary digit and is the smallest unit of data computers deal with.

Quantum computers deals in quantum bits or qubits.

Read about Bits on Wikipedia and GCSE Bitsize

Byte

A group of 8 Bits

What is the maximum value of a byte?

Remember there are 8 Bits in a Byte!

That's right, 255!? 😕

Tip:

In C# we can find the value easily:

Byte.MaxValue

Explain yourself

A byte can be represented in a table.
From right to left, each binary value has a position.
If all values are set to 1 or true.

128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255!

Where do these positions come from?

  • Remember Binary is base 2?
    • Positions in a byte come from the 2 to the power of ...
128 64 32 16 8 4 2 1
27 26 25 24 23 22 21 20

Activity - What's that binary value?

Fill in the decimal and Binary values on the cards you are given.

8-bit colours

  • Computers can store colours in 8-bits.
    • 8-bits for each primary colour, this is called RGB.

Here is a nifty RGB colour calculator on W3Schools.com.
Take some time to explore RGB colours

Other Units of data

A byte is not the biggest, the size of data units goes on...

Name Equals Bytes
Bit 1 bit 1/8
Nibble 4 bits 1/2
Byte 8 bits 1
Kilobyte 1,024 bytes 1,024
Megabyte 1,024 kilobytes 1,048,576
Gigabyte 1,024 megabytes 1,073,741,824
Terrabyte 1,024 gigabytes 1,099,511,627,776
Petabyte 1,024 terrabytes 1,125,899,906,842,624
Exabyte 1,024 petabytes 1,152,921,504,606,846,976
Zettabyte 1,024 exabytes 1,180,591,620,717,411,303,424
Yottabyte 1,024 zettabytes 1,208,925,819,614,629,174,706,176

Why 1024 not 1000?

Remember binary is base 2, computers are base 2.
210 = 1024.

But it is okay for you to say 1000 in the exam. 😌

Binary math

Adding

8 4 2 1
0 0 1 1
+ 1 0 0 0
1 0 1 1

What is this? 3 + 8 = 11

Carry the one

8 4 2 1
0 1 1 0
+ 01 11 1 1
1 1 0 1

What is this? 6 + 7 = 13

Overflow

128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
+ 01 01 01 01 01 01 01 1
1 0 0 0 0 0 0 0 0
  • What is this? 255 + 1 = 0??!! 🤯
    • Remember the maximum of 8-bits is 255.

Of course most PCs are 64-bit (264), maximum is 18 quintillion (18,446,744,073,709,551,615)

Activity

Windows has a nifty calculator that we can use to do binary maths.

Let's get started!

That's all folks!

What have we learnt?

  • Binary is a 1 or a 0, Off or On
    • A Bit is a Binary digit, the smallest unit of data.
  • A Byte is 8 bits
  • There are many Data Units.
    • Kilobyte = 1,024 bytes.
    • Megabyte = 1,024 kilobytes.
    • And many more...
© Luke O'Brien 2018