Go to Google Groups Home    comp.lang.python
Re: decimal and trunkating

Reinhold Birkenfeld <reinhold-birkenfeld-nos...@wolke7.net>

F. Petitjean wrote:
> Le Thu, 02 Jun 2005 19:59:08 +1000, Timothy Smith a écrit :
>> i want to trunkate 199.999 to 199.99

> round(199.999, 2)  # 2 digits after the decimal point

Wrong. This will yield 200.00.

>> do i really have to use floats to do this?

> 19.999  is a float :
> type(19.999) is float  #  ==> True

He is speaking of Decimals...

d = Decimal("199.999")
d._round(5, decimal.ROUND_DOWN)

Reinhold