Floating Point Numbers Flashcards
What is fixed point
- Position Values are set by the binary point
- To the left they double in size (1,2,4)
- to the right of the point they halve in size (0.5, 0.25, 0.125)
how does the computer remember the position of the point
set by the software in use, or occasionally the hardware of the processor
what is range
The difference between the highest and lowest numbers that can be represented
what is precision
the smallest possible fraction that can be represented
what happens if the number of bits is limited?
There is a trade- off between range and precision.
What are the two elements of a floating point number?
mantissa- the pattern of 1s and 0s
exponent - the power of 2 / how much it is to be shifted.
- both are stored with two’s complement
- bits for each vary depending on the question
How does a normalised mantissa begin?
an 01 or a 10. The binary point is between the 1 and 0.
evaluate fixed vs floating point
Fixed point : Less processing, therefore quicker.
Floating point: maximum range and precision.
How to convert floating to fixed point.
- the binary point in the (normalised) mantissa is after the first digit
- find the value of the exponent.
- If it is positive, shift the binary point on the mantissa to the right that many places.
- If it is negative, shift it to the left that many places. this will create empty spaces. Fill these with the bit value (1 or 0 ) that the mantissa starts with.
How to convert fixed to floating point
- find the mantissa - the first 01 or 10 of the number, and all the 1s and 0s after it
- the point of the mantissa is between the 1 and the 0.
- how many hops would it take to move the binary point from that position, to where it belongs in it’s fixed form?
- That number is the exponent.
(if hopped left, exponent is negative. otherwise, positive)
How to normalise a floating point number
- remove “spare” 0s or 1s from the front of the mantissa until it starts with 01 or 10.
- how many you removed, subtract that number from the exponent.
How to add two floating point numbers
- find the smaller exponent, make it lager to match the other
- how much did you add? add that many 1s or 0s to the start of the mantissa
- Now add the mantissas together. The two nums have the same exponent.