From 414eef7858ec64fad38cac5666c8d3ca1e4d0777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schie=C3=9Fl?= Date: Sun, 26 Apr 2020 10:51:40 +0200 Subject: [PATCH] amount.__int__ needs rounding --- graphenecommon/amount.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphenecommon/amount.py b/graphenecommon/amount.py index 350d5107..d0d598e1 100644 --- a/graphenecommon/amount.py +++ b/graphenecommon/amount.py @@ -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()