python rounding problem.

gene tani gene.tani at gmail.com
Sun May 7 09:08:33 EDT 2006


Erik Max Francis wrote:
> chun ping wang wrote:
>
> > Hey i have a stupid question.
> >
> > How do i get python to print the result in only three decimal place...
> >
> > Example>>> round (2.995423333545555, 3)
> > 2.9950000000000001
> >
> > but i want to get rid of all trailing 0's..how would i do that?
>
> Floating point arithmetic is inherently imprecise.  This is not a Python
> problem.
> 

http://www2.hursley.ibm.com/decimal/
(read about IEEE754 here)




More information about the Python-list mailing list