# A-level Computing/AQA/Paper 2/Fundamentals of data representation/Bits and bytes
## Bits and Bytes

The language that a computer understands is very simple, so simple that it only has 2 different numbers: 1 and 0. This number system is called Binary. This is because 1 represents high voltage and 0 to represent low voltage.
A 1 or 0 is called a Bit which is short for BInary DigiT. This is the fundamental unit of information.
Everything you see on a computer, images, sounds, games, text, videos, spreadsheets, websites etc. Whatever it is, it will be stored as a string of ones and zeroes.
* All stored as binary
* Exercise: Bit patterns in a Computer
* How do computers store data?
* Answer:
* as binary values, using a pattern of 1s and 0s
* What sort of data can be stored in binary?
* Answer:
* Video
* Sound
* Picture
* Text
* Code
* Spreadsheet
* Game
* etc
* What does the following binary string represent: 10011100
* Answer:
* This could be anything:
* sound data
* picture data
* text ASCII for œ
* unsigned integer = 156
* video data
* etc
* How many bits in a byte?
* Answer:
* 8, but it is originally the amount of bits used to represent a character
* How many bits in 7 bytes?
* Answer:
* 7 * 8 = 56
* How many different patterns can be made from 4 bits?
* Answer:
* 2$^4$ = 16 different patterns or combinations can be created

## Minimum and Maximum Number vs. Number of Different Values

* From the Specification : Binary number System - Unsigned binary
* Know that in unsigned binary the minimum and maximum values for a given number of bits, n, are 0 and 2$^n$ -1 respectively.
A common question that you'll need to know the answer to, and one that many people get wrong, is a question about the minimum and maximum denary value you can store in a set number of binary digits.
If I were to have 3 binary digits, the minimum value I could store would be 000$_2$ = 0. Whereas, the maximum value that I could store would be 111$_2$, this equates to 4 + 2 + 1 = 7$_{10}$. So for 3 binary digits the range of numbers I can store is 0 (minimum) to 7 (maximum).
* From the Specification : Units of information - Bits and bytes
* Know that the 2$^n$ different values can be represented with n bits.
A similar, but different question, is how many different binary patterns (and therefore values) can you represent with a set number of binary digits. If I were to be asked how many binary patterns can be represented from 3 binary digits, then we have 8 options:
We could count these all out and write down: "There are 8 different values 3 binary digits can take". But this isn't very clever, what is you wanted to find out the range and maximum values for 34 bits, you can't be expected to write them all out.
We are looking for a rule to save us the job and stop us making mistakes. Can you work out a rule in terms of $n$ for:
Maximum denary value of $n$ binary digits:
Number of different values/binary patterns for $n$ binary digits:

### Example

2 bits can be configured in 2$^2$ = 4 different ways. 3 bits can be configured in 2$^3$ = 8 different ways.
| 2 bits | 3 bits |
| 00 01 10 11 | 000 001 010 011 100 101 110 111 |
| Min = 0 | Min = 0 |
| Max = 2$^2$-1 = 3 | Max = 2$^3$-1 = 7 |
| 2$^2$ = 4 | 2$^3$=8 |
| 4 combinations | 8 combinations |
* Exercise: Max and range of binary numbers
* Give both the maximum value and number of different values for the following n binary digits:
* 4
* Answer:
* Maximum : $2^{n}-1=2^{4}-1=16-1=15$
* Range : $2^{n}=2^{4}=16$
* 5
* Answer:
* Maximum : $2^{n}-1=2^{5}-1=32-1=31$
* Range : $2^{n}=2^{5}=32$
* 8
* Answer:
* Maximum : $2^{n}-1=2^{8}-1=256-1=255$
* Range : $2^{n}=2^{8}=256$
* 10
* Answer:
* Maximum : $2^{n}-1=2^{10}-1=1024-1=1023$
* Range : $2^{n}=2^{10}=1024$
* For an address bus with 6 wires, what is the highest address that can be given? How many addresses can accessed?
* Answer:
* highest address : $2^{n}-1=2^{6}-1=64-1=63$
* Different number of addresses : $2^{n}=2^{6}=64$
* This is a very popular exam question!