How is Data Represented?
A bit is a single piece of information - it's either 0 or 1.
A nibble is 4-bit. This means it's a sequence of 4 digits.
A byte is 8-bit. This codes 8 digits.
Binary
Binary is machine code. In Binary, every digit is represented as either a 1 or a 0. Binary works in multiples of 2.
The digits: 8 4 2 1 represent a nibble. This is 4-bit.
The digits: 128 64 32 16 8 4 2 1 represent a bit. This is 8-bit.
All the digits are represented by either a 1 or 0. For example:
0001 1001 = 25
Because...
128\
|128| 64 | 32 |16 | 8 | 4| 2 | 1 |
| 0 | 0 | 0 |1 |1 |0| 0| 1|
And 16+8+1 = 25
Hex
Instead of working in multiples of 2, Hex works in multiples of 16, it's called Base 16.
32 in decimal means that there are 3 tens and 2 left over.
32 in Hex means that there are 3 multiples of 16 and 2 left over.
So, 3 * 16 = 48, 48+2 = 50. 32 in hex means the decimal number 50.
50 is written in binary as 0011 0010.
ASCII
ASCII stands for American Standard Code for Information Interchange. It is used to represent characters:
- Upper and lower case letters (52 characters)
- All the numeric symbols (10 characters)
- Punctuation and Space (33 characters)
- Non printable code (32 characters)
32 in decimal means that there are 3 tens and 2 left over.
32 in Hex means that there are 3 multiples of 16 and 2 left over.
So, 3 * 16 = 48, 48+2 = 50. 32 in hex means the decimal number 50.
50 is written in binary as 0011 0010.
ASCII
ASCII stands for American Standard Code for Information Interchange. It is used to represent characters:
- Upper and lower case letters (52 characters)
- All the numeric symbols (10 characters)
- Punctuation and Space (33 characters)
- Non printable code (32 characters)
The http://www.mathsisfun.com/binary-number-system.html
Instruction Set
An instruction set is the instructions used by the CPU to run a program. It tells the CPU what to do.
To run a program, the CPU must go to the start address, from there it decodes its first instructions and finds out what to do next.
Both instructions and data are written in Binary code. The CPU cannot differentiate between the two. If the CPU expects to find instructions, it will find it and decode it.
Examples of Instruction Set
ADD - Add two numbers together.
COMPARE - Compare two numbers.
IN - Input information.
JUMP - Jump to a location in the RAM.
Instruction sets are written in 2 parts: operator and operand.
The operator tells the CPU what to do. The operand gives the location.
The Instruction Set can be embedded in the processor or part of the software.
Representation of Images
Images are stored in binary and are made up of pixels. When representing colour, we use bits per pixel. 1 bit represents two colours:
0 = Black
1 = White
With 8 bits, we can represent 256 colours. Colour depth is the number of bits per pixel. To get a better quality image, more bits must be used. That way, more colours can be encoded into the image.
Resolution is the number of pixels per unit of measurement. The higher the resolution, the clearer the image will be.
Meta data provides information about an image that the computer can use. Meta data includes:
- The height and width of an image,
- The colour depth,
- The resolution,
- camera used and when the image was taken.
Representation of Sound
Sound is also stored in binary. The computer converts sound (which is continuously varying data) into digital data by sampling the sound wave at regular intervals. The frequency of this is called Sample rate.
How much data is stored per second is called the bit rate. When we store the sound file, the higher the bit rate, the better quality of file. However, this will mean a larger file.
Development Software
EDITORS:
Programs must be written in an editor, like a simplified word processor. Editors can come with 'Pretty Printing'. This is very useful to the programmer as it can identify code such as strings and loops and automatically indent them or change the colour. They can also show line numbering.
COMPILERS:
High Level Languages look like normal english, they make coding much easier for the programmer. The code written by the programmer in these languages are called the source code. However, source code can't be read by the CPU so it must be translated into machine code. The compiler is responsible for this. It works as a translator, converting high level languages into code used by the CPU
INTERPRETERS:
Interpreters are similar to Compilers. However, they translate each line of code one at a time and execute the code after it has been translated. They are slower because of this. Also someone must
have the correct interpreter to run a program.
ASSEMBLY LANGUAGE:
Assembly Language makes writing machine code programs easier. It uses mnemonics to represent machine operations. It allows the programmer complete control over their code, however it takes longer because of this. Assembly language is unique to the processor that is running it. Assembly language must be converted into machine code by an Assembler.
LINKERS:
Linkers allow programs to be built from subprograms. Different parts of programs can be written in different languages with different tools. These are put together by Linkers, literally, linking the separate sub programs together. They also ensure that once the program has been put together, that it runs smoothly.