4.5 Data representation Flashcards
Write down the natural numbers
{ 0, 1, 2, 3, …}
What are ordinal numbers?
Natural numbers used to describe the numerical position of a value. e.g. in the alphabet (1st 2nd etc.)
Why use hexadecimal?
Long sequences of binary digits are hard for humans to read and understand, so hexadecimal is often used as a shorthand
How many bytes in a megabyte?
One million
How many bytes in a mebibyte?
1024^2 (or 2^20)
List the prefixes starting kibi…
- kibi
- mebi
- gibi
- tebi
What is the significance of the leftmost bit in two’s complement?
The most significant bit (leftmost) is the sign bit, which represents a negative number when set to 1
What is 1111…111 in two’s complement binary?
-1
Range of 8 bits for:
1. unsigned binary number
2. two’s complement number
Unsigned: 0 to 255
Two’s complement: -128 to 127
The sum of two 8-bit two’s complement binary numbers can be between ___ and ___
-128 and 127
(Can ignore the overflow in this case)
How to turn a negative number into a positive number in two’s complement (and vice versa)?
- From the right, up to and including the first 1 stays the same.
- Everything other value gets flipped.
(This is the same as flipping everything then adding 1)
How to subtract two binary numbers A - B?
- Convert B into two’s complement
- Add this to A
How can you identify normalised floating point numbers?
Mantissa must begin with 01 or 10
2 advantages of normalisation of floating point numbers
- It maximises precision for a given number of bits
- It ensures that there is a unique representation of each number, making it simpler to test for equality of numbers
If the exponent of a number is negative, what do you need to do to the mantissa when converting from binary to decimal?
Fill in with 0s if the leftmost bit is a 0, and fill in 1s if its a 1.
Advantages of fixed point binary numbers
- More representable numbers, as numbers don’t need to be normalised
- Maximum precision for the given number of bits
- Can be simpler, and faster, to work with
3 advantages of floating point numbers
- Can represent a much larger range of numbers
- The trade-off between range and precision can be tailored to the context the system is being used in
- Additional non-numeric values can be represented using the unnormalised range (e.g. NaN, infinity)
What is meant by the precision of a binary number?
The maximum number of significant digits that can be represented in a number format.
When the result of an arithmetic operation is a real number (e.g. pi), what options are there for storing it in binary?
- Rounding to the nearest representable value
- Truncating
What is absolute error?
The difference between the actual value and the nearest representable value
(always positive)
What is relative error?
The absolute error ÷ the actual value
(could be given as 0.05, 1/20 or 5%)
When does overflow occur?
When a number is too large to be represented using the available number of bits
When does underflow occur?
When a number is too small to be represented using the available number of bits
What is a character set?
A character set is a standardised collection of characters and the bit-patterns used to represent them