Skip to content

Commit

Permalink
amount.__int__ needs rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Schießl authored Apr 26, 2020
1 parent 8aef51a commit 414eef7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion graphenecommon/amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def __float__(self):
return float(self["amount"])

def __int__(self):
return int(self["amount"] * 10 ** self["asset"]["precision"])
# this needs rounding, e.g. 5.1 * 10 ** 5 == 509999.99999999994
return int(round(self["amount"] * 10 ** self["asset"]["precision"]))

def __neg__(self):
a = self.copy()
Expand Down

0 comments on commit 414eef7

Please sign in to comment.