Significant digits in a float?

Chris Angelico rosuav at gmail.com
Mon Apr 28 12:28:59 EDT 2014


On Tue, Apr 29, 2014 at 2:00 AM, Roy Smith <roy at panix.com> wrote:
> I have a bunch of floating point values.  For example, here's a few (printed as reprs):
>
> 38.0
> 41.2586
> 40.75280000000001
> 49.25
> 33.795199999999994
> 36.837199999999996
> 34.1489
> 45.5
>
> Fundamentally, these numbers have between 0 and 4 decimal digits of precision...

Terminology question: Why do you count only what's after the decimal
point? I would describe these as having between 2 and 6 significant
figures. Will they always have two digits before the decimal, or does
your precision really care only about what's after it?

Of course, there would still remain the problem of describing 49.25
with 6 sig figs, in the same way that it's hard to explain to someone
that you really do need to leave in five minutes (but if you said you
had to leave in six minutes, they'd believe you to be accurate to the
minute). But I assume that's not part of the question.

ChrisA



More information about the Python-list mailing list