Join 36000+ teachers and students using TTIO.
If you use more bits in the exponent, the range can be greater. If, however, more bits are used for the mantissa, the precision of the number can be increased.
Interesting note: No matter how many digits you’re willing to write down, the result will never be exactly 1/3, but will be an increasingly better approximation of 1/3.
In the same way, no matter how many base 2 digits you’re willing to use, the decimal value 0.1 cannot be represented exactly as a base 2 fraction. In base 2, 1/10 is the infinitely repeating fraction
0.0001100110011001100110011001100110011001100110011...
Stop at any finite number of bits, and you get an approximation. On most machines today, floats are approximated using a binary fraction with the numerator using the first 53 bits starting with the most significant bit and with the denominator as a power of two. On most machines, if Python were to print the true decimal value of the binary approximation stored for 0.1, it would have to display>>>
>>> 0.1
0.1000000000000000055511151231257827021181583404541015625
www.teachyourselfpython.com