From aed3836af1d72789128de7377f88d3f8fa5220c0 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Mon, 18 Jul 2022 09:50:26 +0300 Subject: [PATCH] refactor isPowerOverflow128 --- assembly/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assembly/utils.ts b/assembly/utils.ts index 8ab4e2e..3cba562 100644 --- a/assembly/utils.ts +++ b/assembly/utils.ts @@ -57,9 +57,11 @@ import { u256 } from "./integer/u256"; // @ts-ignore: decorator @inline export function isPowerOverflow128(base: u128, exponent: i32): bool { - if (!(exponent > 1 && base > u128.One)) { + // never overflow + if (exponent <= 1 || base <= u128.One) { return false; } + // always overflow if (base.hi != 0 || exponent >= 128) { return true; }