Skip to content

Commit

Permalink
refactor minValue and maxValue
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Feb 27, 2025
1 parent 0b261fe commit 215f5cc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/esaulpaugh/headlong/abi/UnitType.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public final boolean isUnsigned() {
}

public final BigInteger minValue() {
return unsigned ? BigInteger.ZERO : BigInteger.valueOf(2L).pow(bitLength - 1).negate();
return unsigned ? BigInteger.ZERO : BigInteger.ONE.shiftLeft(bitLength - 1).negate();
}

public final BigInteger maxValue() {
return BigInteger.valueOf(2L)
.pow(unsigned ? bitLength : bitLength - 1)
return BigInteger.ONE
.shiftLeft(unsigned ? bitLength : bitLength - 1)
.subtract(BigInteger.ONE);
}

Expand Down

0 comments on commit 215f5cc

Please sign in to comment.