FC18: Fixed NCR1632 max value check

This commit is contained in:
Willem Cazander 2025-08-07 17:44:54 +02:00
parent c86e90fee7
commit d0e68f4d7b

View file

@ -134,7 +134,7 @@ final public class FourCornerRecipe {
}
static final private BigInteger NCR1632_MASK_PAGE = BigInteger.valueOf(0x1FF);
static final private BigInteger NCR1632_MASK_MAX = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
static final private BigInteger NCR1632_VALUE_MAX = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
static private List<Integer> embedNCR1632Value(List<Integer> result, BigInteger value, int bankStart) {
if (value.equals(BigInteger.ZERO)) {
@ -143,7 +143,7 @@ final public class FourCornerRecipe {
//if (value.signum() == -1) {
// // TODO: check if we need one octal for pos/neg/qNaN/sNaN/pos_inf/neg_inf/free/free options
//}
if (value.and(NCR1632_MASK_MAX).equals(BigInteger.ZERO)) {
if (value.compareTo(NCR1632_VALUE_MAX) > 0) {
throw new IllegalArgumentException("Value is larger than 576 bit: " + value);
}
BigInteger valueZero = value.subtract(BigInteger.ONE);