Timothy Smith <[EMAIL PROTECTED]> wrote:
> i want to trunkate 199.999 to 199.99
> getcontext.prec = 2 isn't what i'm after either, all that does is E's 
> the value.
> do i really have to use floats to do this?

You could try this (from a script I use for my phone bill):

from decimal import Decimal as d

def roundDecimal(num, prec):
    return d(num).quantize(d("1e%d" % (-prec)))

where `prec` is the number of places after the decimal point.

I'm sure there is a better solutions and someone will tell it, thereby
teaching us both. ;-)

Adiaŭ, Marc
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to