fix: incorrect rounding off near zero (#28948) (#28949)

(cherry picked from commit 0724a148e6)

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
mergify[bot]
2021-12-18 21:36:17 +05:30
committed by GitHub
parent 5a6ea7a829
commit f2464ce04a

View File

@@ -1157,7 +1157,7 @@ def _round_off_if_near_zero(number: float, precision: int = 6) -> float:
""" Rounds off the number to zero only if number is close to zero for decimal
specified in precision. Precision defaults to 6.
"""
if flt(number) < (1.0 / (10**precision)):
return 0
if abs(0.0 - flt(number)) < (1.0 / (10**precision)):
return 0.0
return flt(number)