[Tutor] list output -- float output

Lie Ryan lie.1296 at gmail.com
Fri Nov 14 18:23:59 CET 2008


On Fri, 14 Nov 2008 15:21:17 +0100, spir wrote:
> Well, actually not really I guess. I asked for rounded floats, not
> full-precision ones.
> Now, after more reflexion on the topic, I understand that even rounded
> floats need to keep full precision internally, because of the 'modular'
> difference between decimal and binary representations that causes
> 'epsilon' errors; which still applies on rounded floats, for the
> rounding operates at the decimal level. In other words, (decimal)
> rounding does not eliminate the source of 'little errors' -- it should
> be binary rounding instead, but this is probably not very useful for us
> in the real world ;-). The reason why repr(), that shows inner
> representation, is still full of junk digits for rounded floats, while
> str() shows the expected format. denis


If you wanted a more controllable precision and can tolerate being a bit 
slow, you can use the Decimal module instead.



More information about the Tutor mailing list