How to detect a double's significant digits

Erik Max Francis max at alcyone.com
Thu May 5 23:08:46 EDT 2005


Jeremy Bowers wrote:

> Not necessarily; consider the str() of a float in Python, especially given
> the "significant digits" aspect (it may be ill-defined, but I can think of
> several well-defined ways to mean that, where str() embodies one of them).
> The easiest way to tell how long the number will be when str prints it out
> is to simply ask it.

Grant's point was that as significance is used in scientific studies, 
there's no way to answer the question without having the number in 
advance.  If I say that the length of something is 1100 m, you don't 
know whether I mean 1.1 x 10^3 m, 1.10 x 10^3 m, 1.100 x 10^3 m, etc. 
These all have different significances.  The figure 1100 m can't tell 
you how many significance figures are involved without further information.

In particular, the example he gave involved changing significance 
depending on the number of zeroes _before_ the other digits, not after 
them, which is now how significance works.  So obviously when he says 
"significant digits" he doesn't mean the same thing that's used by 
scientists, so the question can't really be answered.

If he simply wanted to get the number of digits involved, then that's 
fine, but that's not what significance is.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Eternity is very long, especially near the end.
   -- Woody Allen



More information about the Python-list mailing list