From d06c397a5c600ae7380e7fe9fb3338532c996de8 Mon Sep 17 00:00:00 2001 From: Claudia Richoux Date: Thu, 27 Aug 2020 20:28:55 -0400 Subject: [PATCH] fixing it and supporting base of zero --- slither/slithir/variables/constant.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/slither/slithir/variables/constant.py b/slither/slithir/variables/constant.py index 9be1bbc59..dd9df153b 100644 --- a/slither/slithir/variables/constant.py +++ b/slither/slithir/variables/constant.py @@ -25,18 +25,16 @@ class Constant(SlithIRVariable): if val.startswith('0x') or val.startswith('0X'): self._val = int(val, 16) else: - if 'e' in val: - base, expo = val.split('e') - expo = int(expo) + if 'e' in val or 'E' in val: + base, expo = val.split('e') if 'e' in val else val.split('E') + base, expo = Decimal(base), int(expo) if expo > 80: - raise ValueError("exponent is too large to fit in any Solidity integer size") - self._val = int(Decimal(base) * (10 ** expo)) - elif 'E' in val: - base, expo = val.split('E') - expo = int(expo) - if expo > 80: - raise ValueError("exponent is too large to fit in any Solidity integer size") - self._val = int(Decimal(base) * (10 ** expo)) + if base != Decimal(0): + raise ValueError("exponent is too large to fit in any Solidity integer size") + else: + self._val = 0 + else: + self._val = int(Decimal(base) * (10 ** expo)) else: self._val = int(Decimal(val)) elif type.type == 'bool':