13 ms·
Sorry, I am doing stuff in the function... here is one of the old ones from code I can share def dec(value, prec=4): """Return the given value as a
by leetrout 5y ago
Sorry, I am doing stuff in the function... here is one of the old ones from code I can share
def dec(value, prec=4):
"""Return the given value as a decimal rounded to the given precision."""
if value is None:
return Decimal(0)
value = Decimal(value)
ret = Decimal(str(round(value, prec)))
if ret.is_zero():
# this avoids stuff like Decimal('0E-8')
return Decimal(0)
return ret