Part 1 Block 1 - Floating Point Flashcards
Convert the following binary number into decimal.
101.011
5.375
To represent a float in binary scientific notation, we have powers of ____ (rather than powers of 10) and the mantissa always starts with a ___________, followed by a decimal point.
powers of 2
starts with a 1
So, –10101.1 in binary notation can be written as –1.01011 × 2^_________ in binary scientific notation.
2^4
In Binary Scientific notation, where is the ‘sign’ stored, and how is a positive and a negative sign represented?
The sign in stored in the leftmost bit.
1 = negative
0 = positive
In a typical computer, a float is stored in _____ bytes
4 bytes
(so, 32 numbers)
Binary Scientific Notation
As we know, the sign is stored in the first bit on the left. What do the next 8 bits store?
The exponent part (aka - the main number before the decimal point)
Binary Scientific Notation
What do the last 23 bits store?
The fractional part of the Mantissa.
When representing a fraction like 1/3 in decimal, we can only make an approximation of it, e.g. 0.3 or closer 0.33, or closer 0.333.
Can we get closer to the fraction in a binary representation, i.e. by adding more and more bits in a similar way?
No, we cannot.
In decimal which part of the following number is the mantissa?
6.02 x 10^23
6.02
In decimal which part of the following number is the exponent?
6.02 x 10^23
23
When programming in any language why should we never compare floats?
e.g is 0.1 + 0.1 + 0.1 == 0.3?
We would get an unexpected answer of false due to the precision problems of Binary.
0.1 in binary is represented as:
0.00011001100110011001100110011001100110011001100110011010
This is actually:
0.1000000000000000055511151231257827021181583404541015625 in denary, so we are not going to get 0.3 if we add that number together three times!
In Python, if we use the .round( ) method,
would we round the seven up, down or leave it as 7?
7.432
leave it as 7
In Python, if we use the .round( ) method,
would we round the 7 up, down or leave it as 7?
7.624
Round up
In Python, if we use the .round( ) method,
would we round the 7 up, down or leave it as 7?
7.544
It would be rounded up, as 7 is an odd number.
In Python, if we use the .round( ) method,
would we round the 12 up, down or leave it as 12?
12.567?
Leave it as 12.
12 is an even number.
Even numbers and zeros remain the same.