Skip to content

Commit

Permalink
refactor isPowerOverflow128
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGraey committed Jul 18, 2022
1 parent e7a2499 commit aed3836
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion assembly/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit aed3836

Please sign in to comment.