How to detect a double's significant digits

phil phillip.watts at anvilcom.com
Thu May 5 15:16:34 EDT 2005


Bollocks, works here.

That looks like Java!!!  Aaaihh!

mrstephengross wrote:

> Ok, that won't work. First of all, str() is not a function. If I want
> to convert the float into a string, the conversion function will have
> to use some kind of numeric precision, which will screw things up.
> Consider this:
> 
> float f = 1.004;
> ostringstream s;
> s << f;
> cout << s.str();
> 
> The above code may produce "1.004", or "1.0040", or "1.00400",
> depending on the stream's precision setting. I need a way to detect the
> number of digits to the right of decimal point *prior* to doing any
> kind of string conversion.
> 
> --Steve
> 
> 






More information about the Python-list mailing list