1.4 Data Representation and Data Types Flashcards
What is a bit? (2)
- A single “1” or “0”
- Is the smallest unit of data.
What is a byte?
A sequence of 8 bits.
What is a word? (2)
- The number of bits that can be simultaneously processed or stored in a single register.
- Different for different computers
How many bits are there in a word?
It is usually 32 or 64 bit.
What is the binary number system?
- It stores data via an arrangement of 1 and 0.
- It is a base 2 system.
What is hexadecimal? (2)
- A way of writing binary using letters and numbers.
- It is a base 16 system.
How can hexadecimal be used as shorthand?
The binary number can be split into groups containing 4 digits/bits and represented by a number.
What are the advantages of using
hexadecimal?
Fewer errors will occur as it is easy to read a large binary number.
What are character sets?
A list of characters alongside corresponding binary codes.
How do character sets work?
When a computer stores text, it stores a sequence of binary codes, and two computers that use the same character set can communicate with one another.
Give 2 character sets.
- ASCII
- Unicode
How does ASCII store characters?
It stores characters that can be found on standard UK keyboards using 7bits per character.
How does Unicode store characters?
It stores a huge range of characters from many languages, as well as emoticons and other symbols, using 16 bits per character.
Give an advantage for ASCII.
Very little storage space required per character.
Give a disadvantage for ASCII.
Limited to using western characters only.
Give 2 advantages for Unicode.
- Many more characters can be used.
- Possibility to store more in the future.
Give a disadvantage for Unicode.
Requires more than double the storage space per character of ASCII.
What is a primitive data type? (2)
- A primitive data type is a data type that cannot be broken down into smaller data types.
- A variables data type determines what can be stored in that variable.
What is a variable?
A named space in memory that can contain one piece of data of a specified data type.
State 5 data types.
- Boolean
- Character
- String
- Integer
- Real
What is a Boolean?
Can only be True or False.
What are the storage requirements of a Boolean?
1 bit
What is a Character?
Stores content of a single keystroke.
What are the storage requirements of a
Character? (2)
- For ASCII : 7 bit
- For Unicode : 16 bit
What is a String?
A sequence of characters.
What are the storage requirements of a
string?
Number of characters in string, 7 (if ASCII) or 16 (if Unicode).
What is an Integer?
Whole numbers including positives, negatives and zero.
What are the storage requirements of an Integer?
Variable - longer it is the more bits needed.
What is a Real?
Numbers that can contain fractions and decimal points.
What are the storage requirements of a
Real?
Variable - More bits allow storage of larger numbers and more precise fractions.
What is an arithmetic shift to the right of n places?
Equivalent of dividing by 2^n.
What is the difference between an arithmetic shift and a logical shift?
An arithmetic shift maintains details with the sign bit. A logical shift does not.
What are the two ways an integer
can be stored in fixed length?
- Sign and Magnitude
- Two’s Compliment
What is sign and magnitude? (2)
- The first bit in the sequence is a sign bit and has no numerical value.
- 0 : positive, 1 : negative
What does the placeholder for sign and magnitude look like?
(-) 64 32 16 8 4 2 1
What is Two’s Compliment?
The left most bit is negative.
What does the placeholder for Two’s Compliment look like?
-128 64 32 16 8 4 2 1
What is a way to store an unfixed length?
Unsigned fixed points.
What is the placeholder for an unsigned
fixed point with the point after 4 bits?
8 4 2 1 .5 .25 .125 .0625
What is another way in which a computer stores numbers?
Floating point form
What is floating point form? (2)
- It is the binary equivalent to standard form.
- It consists of a Mantissa and an Exponent (M x 2ᴱ).
State 2 advantages of using integer form to store numbers.
- For small values, data stored in this format required less storage space.
- There is no overhead - no need to calculate the values before processing it.
State 2 disadvantages of using integer form to store numbers.
- Fractions can not be stored.
- For an extremely large number (eg Trillion) an integer would require far more storage space than floating point.
State 3 advantages of using floating point form to store numbers.
- Fractions can be stored.
- Extremely large numbers require fewer bits to store compared to integer form.
- Can store numbers completely precisely/ accurately
State 2 disadvantages of using floating point form to store numbers.
- For small integer values (eg 32) more bits are used than would be in integer form
- There is an overhead – processor time is needed to calculate the value stored before it can be processed.
State 2 ways to approximate numeric data.
- Truncation
- Rounding
What does rounding do?
It takes a number to the nearest integer or (in binary) the nearest half, quarter, eighth.
Give an example of rounding.
7.8 —-> 8
What does truncation do?
It disregards values after a certain number of digits relative to the binary (or decimal) point.
Give an example of truncation.
7.8 —-> 7
Why is rounding generally more appropriate than truncation?
Rounding tends to give answers nearer to the original number.
State 3 errors caused by rounding and truncation.
- A continued use in further calculation increases inaccuracy.
- A test for equality might fail if a minor difference is caused by rounding.
- In some applications a high accuracy is vital and rounding may reduce this accuracy.
When does an underflow occur?
When a number is very close to zero to be stored by the computer.
When does an overflow occur?
When a number is too large to be stored by a computer.