-
Notifications
You must be signed in to change notification settings - Fork 15
Fix missing_constant not suppressing min/max range errors in ASCII tables #1664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,16 +184,24 @@ | |
| } | ||
| } | ||
| } | ||
| boolean hasDecimalPoint = constant_repr.contains("."); | ||
| boolean hasScientificNotation = (constant_repr.contains("E") || constant_repr.contains("e")) | ||
| && !constant_repr.startsWith("0x") && !constant_repr.startsWith("0X"); | ||
| boolean repr_decimal = hasDecimalPoint || hasScientificNotation; | ||
|
Check warning on line 190 in src/main/java/gov/nasa/pds/tools/validate/SpecialConstantChecker.java
|
||
| // For ASCII numeric fields, the value arrives as BigDecimal. Compare directly | ||
| // against a decimal constant representation to avoid lossy BigDecimalβDoubleβBigInteger | ||
| // conversion that causes missing_constant values like "-.99999" to never match. | ||
| if (number instanceof BigDecimal && repr_decimal) { | ||
|
Check warning on line 194 in src/main/java/gov/nasa/pds/tools/validate/SpecialConstantChecker.java
|
||
| BigDecimal constant = SpecialConstantBitPatternTransforms.asBigDecimal(constant_repr, radix); | ||
| return constant.compareTo((BigDecimal) number) == 0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Big thumbs-up for |
||
| } | ||
| if (number instanceof BigDecimal) number = ((BigDecimal)number).doubleValue(); | ||
| if (number instanceof Byte) number = BigInteger.valueOf(number.byteValue()); | ||
| if (number instanceof Double) number = BigInteger.valueOf(Double.doubleToRawLongBits((Double)number)); | ||
| if (number instanceof Float) number = BigInteger.valueOf(Float.floatToRawIntBits((Float)number) & 0xFFFFFFFFL); | ||
| if (number instanceof Integer || number instanceof UnsignedInteger) number = BigInteger.valueOf(number.intValue()); | ||
| if (number instanceof Long || number instanceof UnsignedLong) number = BigInteger.valueOf(number.longValue()); | ||
| if (number instanceof Short) number = BigInteger.valueOf(number.shortValue()); | ||
| boolean repr_decimal = constant_repr.contains (".") || | ||
| ((constant_repr.contains("E") || constant_repr.contains("e")) && | ||
| !(constant_repr.startsWith("0x") || constant_repr.startsWith("0X"))); | ||
| if (repr_decimal) { | ||
| BigDecimal constant = SpecialConstantBitPatternTransforms.asBigDecimal(constant_repr, radix); | ||
| return constant.equals (number); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the hexadecimal exclusion here applies only to scientific notation, not to the decimal-point test. That means something like
0x1.23is still classified asrepr_decimal.This is not a regression, as the behavior already existed before this pull request. Maybe something to note for the future.