Conversation
…er, FloatingPointType)`
…nteger, BigInteger, int, int)` We have two deprecated arguments here, and users are supposed to choose how to replace `FormulaType.getFloatingPointType()`, and if the hidden bit is supposed to be counted or not
| staticImports = | ||
| "org.sosy_lab.java_smt.api.FormulaType" | ||
| + ".getFloatingPointTypeFromSizesWithoutHiddenBit") | ||
| @SuppressWarnings("InlineMeSuggester") |
There was a problem hiding this comment.
Why is inline me not working anymore? Sometimes its a little tricky to find the correct expression for it.
There was a problem hiding this comment.
I removed this one because the user is supposed to choose between getFloatingPointTypeFromSizesWithHiddenBit and getFloatingPointTypeFromSizesWithoutHiddenBit for the replacement
| @Deprecated( | ||
| since = "2026.01, because mantissa arguments with/without sign bits can be misleading", | ||
| forRemoval = true) | ||
| @SuppressWarnings("InlineMeSuggester") |
There was a problem hiding this comment.
Why is inline me not working anymore? Sometimes its a little tricky to find the correct expression for it.
There was a problem hiding this comment.
It wasn't working before 😉 These warnings showed up after I removed some redundant checks and the method was just a single expression. Now that some null checks have been added again the @SuppressWarnings isn't actually needed, and I removed it again
| floatingPointType.getExponentSize(), | ||
| floatingPointType.getMantissaSizeWithoutHiddenBit()); | ||
| Preconditions.checkArgument( | ||
| exponent.compareTo(BigInteger.ZERO) >= 0, "Exponent must not be negative"); |
There was a problem hiding this comment.
You can use the BigInteger signum for this.
There was a problem hiding this comment.
Thanks for the hint!
| @Deprecated( | ||
| since = "2026.01, because mantissa arguments with/without sign bits can be misleading", | ||
| forRemoval = true) | ||
| @SuppressWarnings("InlineMeSuggester") |
There was a problem hiding this comment.
Why is inline me not working anymore? Sometimes its a little tricky to find the correct expression for it.
| FloatingPointType.class, | ||
| FormulaType.getSinglePrecisionFloatingPointType(), | ||
| FormulaType.getDoublePrecisionFloatingPointType()); | ||
| setDefault(FloatingPointType.class, getSinglePrecisionFloatingPointType()); |
There was a problem hiding this comment.
Seems like we set this twice now?
There was a problem hiding this comment.
Yes, you're right. I've removed the setDefault
| */ | ||
| public static FloatingPointType getFloatingPointTypeFromSizesWithHiddenBit( | ||
| int exponentSize, int mantissaSizeWithHiddenBit) { | ||
| checkArgument( |
There was a problem hiding this comment.
Maybe we should stick to the standards wording here, in that it should be "greather than 1".
From:
:sorts-description "All nullary sort symbols of the form
(_ FloatingPoint eb sb),
where eb and sb are numerals greater than 1."
There was a problem hiding this comment.
Thanks, I've updated the error messages
| // size with hidden bit | ||
| var exponentSize = floatingPointType.getExponentSize(); | ||
| var mantissaSizeWithoutHiddenBit = floatingPointType.getMantissaSizeWithoutHiddenBit(); | ||
| Preconditions.checkArgument(exponentSize >= 0, "Exponent size must not be negative"); |
There was a problem hiding this comment.
We should check this only once, and that location is clearly the type (so that we are failing early). This also applies to the other duplicate checks in this class.
There was a problem hiding this comment.
Thanks, the extra check has been removed
| Preconditions.checkArgument( | ||
| mantissa.compareTo(BigInteger.ZERO) >= 0, "Mantissa must not be negative"); | ||
| Preconditions.checkArgument( | ||
| exponent.bitLength() <= floatingPointType.getExponentSize(), |
There was a problem hiding this comment.
No, I think this should be fine. The exponent may have leading zeroes that are not counted by BigInteger.bitLength
|
@kfriedberger is this change/idea OK for you? |
We already have `setDistinctValues`, making the `setDefault` redundant
Hello,
after #513 the only way to create a
FloatingPointNumberis to useFloatingPointNumber.of(String, FloatingPointType)orFloatingPointNumber.of(Sign, BigInteger, BigInteger, FloatingPointType). Both methods accept aFloatingPointTypefor the exponent and mantissa size. Versions ofFloatingPointNumber.of(...)that accept mantissa and exponent size as separate integer arguments have been deprecated as it was not clear if the hidden bit should be included in the mantissa size, or notHowever, when reading out the mantissa/exponent size of there is no way to get the
FloatingPointTypefrom an existingFoatingPointNumber. Instead, the sizes have to be accessed separately thoughFloatingPointNumber.getExponentSizeandFloatingPointNumber.getMantissaSizeWith(out)HiddenBit, which can be error prone:In this PR we try to fix the issue by adding a new method
FloatingPointNumber.getFloatingPointType()to get theFloatingPointTypeof aFloatingPointNumber. We also change the implementation, so that theFloatingPointTypeis stored directly when creating a newFloatingPointNumber, and add some additional sanity checks for the sizes