Skip to content

Commit

Permalink
Merge pull request #52 from Shoobx/local-rounding
Browse files Browse the repository at this point in the history
Do not affect global decimal rounding rules
  • Loading branch information
strichter committed May 17, 2021
2 parents f09d744 + 8668d59 commit 19190ec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions xlcalculator/xlfunctions/math.py
Expand Up @@ -435,9 +435,9 @@ def RADIANS(

def _round(number, num_digits, _rounding=decimal.ROUND_HALF_UP):
number = decimal.Decimal(str(number))
dc = decimal.getcontext()
dc.rounding = _rounding
ans = round(number, int(num_digits))
with decimal.localcontext() as dc:
dc.rounding = _rounding
ans = round(number, int(num_digits))
return float(ans)


Expand Down

0 comments on commit 19190ec

Please sign in to comment.