python rounding problem.
Raymond L. Buvel
levub137 at wi.rr.com
Sun May 7 12:14:19 EDT 2006
Gary Wessle wrote:
> Erik Max Francis <max at alcyone.com> writes:
>
>
>>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.
>
>
> does python support true rations, which means that 1/3 is a true
> one-third and not 0.333333333 rounded off at some arbitrary precision?
>
Python doesn't directly support rationals but there are at least two
third party modules that add this capability to Python.
http://calcrpnpy.sourceforge.net/clnumManual.html
http://gmpy.sourceforge.net/
More information about the Python-list
mailing list