On Thu, 05 May 2005 18:42:17 +0000, Charles Krug wrote: > On 5 May 2005 10:37:00 -0700, mrstephengross <[EMAIL PROTECTED]> > wrote: >> Hi all... How can I find out the number of significant digits (to the >> right of the decimal place, that is) in a double? At least, I *think* >> that's what I'm asking for. For instance: >> >> 0.103 --> 3 >> 0.0103 --> 4 >> 0.00103 --> 5 >> 0.000103 --> 6 >> 0.0000103 --> 7 >> >> Thanks in advance! >> --Steve ([EMAIL PROTECTED]) >> >> > I would say that each of these examples has three signficant figures. Each > of them can be expressed as: > > 1.03e+n > > For any integer n.
You beat me to it. Step one for mrstephengross is to *rigorously* define what he means by "significant digits", then go from there. Since I think he mentioned something about predicting how much space it will take to print out, my suggestion is to run through whatever printing routines there are and get a string out, the measure the string, as anything else will likely be wrong. If that's not possible with the formatting library, you've already lost; you'll have to completely correctly re-implement the formatting library, and not only is that a major PITA, you almost never get it bug-for-bug right... -- http://mail.python.org/mailman/listinfo/python-list