The Issue with Floating Point

In a python REPL environment, we would see the following:

1
2
3
>>> x = 0.1
>>> format(x, '.32f')
'0.10000000000000000555111512312578'

That is x is not actually stored as 0.1 . This is because 1 10 \dfrac{1}{10} cannot be represented as a finite combination of these:

a 1 2 + a 2 2 2 + a 3 2 3 + . \dfrac{a_1}{2} + \dfrac{a_2}{2^2} + \dfrac{a_3}{2^3} + \cdots .

In other words, there is no corresponding binary fraction for 0.1 .

Which of the following can be expressed without any error as a floating point?

0.125 0.3 0.256 0.2

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...