[New-bugs-announce] [issue41598] rnd() + rndup() in math
marco_ocram
report at bugs.python.org
Thu Aug 20 05:39:37 EDT 2020
New submission from marco_ocram <m.balzaretti at eureka-market.com>:
hello, please insert following simple but useful roundings in new lib math.
def rnd(x, n=0):
a = x*10**n
b = int(a)
if abs(a - b) >= 0.5: b += 1 if x >= 0 else -1
return b/10**n
def rndup(x, n=0):
a = x*10**n
b = int(a)
if abs(a - b) > 0: b += 1 if x >= 0 else -1
return b/10**n
thanks a lot, marco.
----------
components: Library (Lib)
messages: 375695
nosy: marco_ocram
priority: normal
severity: normal
status: open
title: rnd() + rndup() in math
type: enhancement
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41598>
_______________________________________
More information about the New-bugs-announce
mailing list