Chapter 4: Representing Data Flashcards
Numbers
Modern computers work in binary because it is easy to represent two states in simple electronic circuits.
- All data, and instructions are in binary.
- Binary is a number system with just two symbols, 0, and 1.
- Each digit in a binary number is called a bit.
Numbers: Converting from binary to denary
The binary number system works like the base 10 system using multiples of 2, instead of 10, for column values. In binary the column values are:
128 64 32 16 8 4 2 1
e.g. what is the binary number 10110 in denary?
128 64 32 16 8 4 2 1
1 0 1 1 0
16 + 4 + 2 = 22
Numbers: Bytes, Kilobytes, Megabytes etc.
A group of 8 bits is called a byte.
Half a byte is called a nibble
Value: Name: 8 bits 1 byte 1024 bytes 1 kilobyte 1024 kilobytes 1 megabyte 1024 megabytes 1 gigabyte 1024 gigabytes 1 terabyte
Numbers: Converting from denary to binary
Work from left to right.
If the column number is smaller than the denary number then put a 1 in it.
e.g. what is 135 in binary?
128 64 32 16 8 4 2 1
1 0 0 0 0 1 1 1
Numbers: Adding binary numbers
Add the values, and it the value is larger than the column will hold in denary you carry it to the next column.
It’s just like adding normally. If it is
0 + 0 = 0
1 + 0 = 1
1 + 1 = put down 0 for that column, and carry the 1
when you carry if it is 1 + 1 + 1 = leave 1 carry 1
e.g. What is 1101 added to 1011 in binary?
1 1 0 1
+ 1 0 1 1
= 1 1 0 0 0
For above: 1st column: 1 + 1 = 0 carry 1 2nd column: 1 + carried 1 = 0 carry 1 3rd column: 1 + carried 1 = 0 carry 1 4th column: 1 + 1 + carried 1 = leave 1 carry 1 5th column: carried 1 = 1
Sometimes we need a ninth binary digit. If our computer onlu has 8 bits to store a value our ninth bit will be lost, This is called overflow. You would then have to add another byte on.
Hexidecimal Numbers
Large binary numbers are difficult to remeber, and programmers want something that is easily converted from binary, but is also easy to remember, or recognise.
A byte splits into two nibbles.
In a nibble the largest value we can store is 1111 = 15
We need different symbols to represent this in one digit.
Base 10 Base 2 Base 16 0 0 0 1 1 1 2 10 2 3 11 3 4 100 4 5 101 5 6 110 6 7 111 7 8 1000 8 9 1001 9 10 1010 A 11 1011 B 12 1100 C 13 1101 D 14 1110 E 15 1111 F
Hex: Converting between hexidecimal, and denary
what is 27 (hex) in base 10? 16 1 2 7 16 x 2 = 32 1 x 7 = 7 32 + 7 = 39
what is BD (hex) in base 10? 16 1 B D 16 x 11 = 176 1 x 13 = 13 176 + 13 + 189
To transfer from base 10 to base 16 just put it in the biggest column it can completely fill, and work from there.
Hex: Converting between hex, and binary
Split the binary byte into two nibbles, and assign them the first four binary columns.
e.g. Convert 10100011 from base 2 to base 16. 8 4 2 1 8 4 2 1 1 0 1 0 0 0 1 1 8 + 2 = 10 2 + 1 = 3 10 is A in hex 10100011 is A3 in hex.
To convert from hex to binary just turn each of the hex digits into a nibble. e.g. what is BD in binary? B = 11 D = 13 8 4 2 1 8 4 2 1 1 0 1 1 1 1 0 1 BD is 10111101 in binary
Characters
- All the symbols displayed by a computer are represented by a code.
- The computer looks up the symbols matching the code from a list of codes, and their associated characters.
- The list of codes, and matching characters is the character set for the computer.
- The codes used are stored in binary.
- The number of bits used to store the code determines how many characters, or symbols can be used.
Examples:
- ASCII used 7 bits so it can provide 127 characters, or symbols plus the null character (128 in total)
- Extended ASCII used 8 bits, and can use 256 characters, or symbols in total.
- Unicode uses 16 bits providing over 65,000 possibilities, or 32 bits providing over 4 billion possibilities. Unicode has a character set with a wide range of specialist symbols.
It keeps the same assignment of codes for the original 127 ASCII codes so ASCII could now be considered a subset of Unicode.
- ASCII codes for characters increase from A to Z, and from a to z. They can be sorted on their numeric code values. If they are sorted, Z comes before a because of its ASCII value e.g. Zebra comes before apple.
Images
Images are stored in lots of binary values on a computer.
The computer is able to work out how to turn these binary values into the images because the file with the binary data contains metadata (data about data).
The height, and width of the image is measured in pixels. A pixel is one dot on the image.
- The number of bits per pixel we have determines how many colours each pixel can represent e.g. 1 bit: 2 colours, 2 bits: 4 colours, 8 bits: 256 colours, 16 bits: 65,536 colours.
- The more bits per pixel (bbp) the greater the colour depth, and the more bits we need to store than data (16bpp is called high colour, 24bpp is called true colour).
- The resolution is the number of pixels per unit e.g. number of pixels per inch/dots per inch (dpi)
The more pixels per inch more data to be stored, and the larger the file needed to store the image. - If a bitmapped image is displayed enlarged on screen, the actual image size does not change, the dots just get bigger, and the image becomes pixelated.
Metadata
Data about data
Sound
Sound files are described by metadata to make sure the computer can accuratly interpret the data.
- The data stored includes the audio codec, and the sample rate.
Sound is an analogue (continuously varying) form so to transfer sound to a computer it needs to be digitally sampled.
The sample interval (time between samples being taken) is often used to describe the sample rate.
- The higher the sample interval, the lower the sample rate.
When sound is sampled at a low rate:
- Very few samples are taken
- There is a poor match between the original sound, and the sampled sound.
- A small file size is required
When sound is samples at a higher rate:
- Many more samples are taken
- There is a good match between the original sound, and the sampled sound
- A large file size is required
The bit rate is the amount of space used for each sample.
A high bit rate means;
- More accurate sampling at each point -> better quality
- More data needs to be stored -> larger file size
A typical MP3 track is stored at 128 kbits per second
An audio CD uses 1411.2 kbits per second
Instructions
When a computer is instructed to run a program it is directed to a specific location in memory that contains the first instruction in the program.
The CPU fetched this instruction, and decodes it in order to find out what to do next.
This instruction is in two parts:
1) Operator: the instruction part
2) Operand: the data part
e.g. is the first location contains 10011011 then
Operator: 1001 Operand: 1011
The opcode (operator binary code) represents an operation e.g 1001 may mean add the contents of the operand to the accumulator.
The operand represents the data that the operator uses e.g. the program adds the value it finds in memory location 1011 to the value in the accumulator
The accumulator is a special register in the CPU used to store the results of any calculation.
The CPU cannot tell the difference between data, and instructions. It simply deals with what it finds according to what it expects to find.