Skip to content

fix: handle scientific notation in multipleOf error aggregation - #290

Merged
jdesrosiers merged 3 commits into
hyperjump-io:mainfrom
Kaileshwar16:fix/289-multipleof-scientific-notation
Oct 18, 2026
Merged

jdesrosiers merged 3 commits into
hyperjump-io:mainfrom
Kaileshwar16:fix/289-multipleof-scientific-notation

Conversation

@Kaileshwar16

Copy link
Copy Markdown
Contributor

Fixes #289.

Calculate combined multiples using exact decimal integer arithmetic, handling scientific notation, mixed precision, and intermediate overflow. Report individual failing constraints when the combined result cannot be represented without precision loss. Preserve localized formatting without rounding small multiples to zero.

Add regression coverage for constraint interactions, locations, localization, and numeric limits. Confirmed the original regression fails before the fix. All 1,416 tests, lint, type

checking, and whitespace checks pass on Node 24.21.0.

The test coverage ended up being a bit larger than the implementation itself, since I tried to cover the numeric edge cases and interactions between constraints. Iam not entirely sure if all of these cases need separate tests, so I am happy to simplify or consolidate them if that would be easier to maintain.

@jdesrosiers jdesrosiers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding this. I think there needs to be a more general solution. Other keywords like minimum and maximum could have the same issue, right?

@Kaileshwar16

Copy link
Copy Markdown
Contributor Author

@jdesrosiers true, multipleOf wasn’t the only one rounding tiny numbers into oblivion 😅 The bounds and success messages had the same issue. I have moved the formatting fix into the shared localization layer, keeping locale formatting and custom Fluent options intact. The BigInt arithmetic stays specific to multipleOf. Added regressions, trimmed some duplicate tests

Kaileshwar16 and others added 3 commits October 18, 2026 14:51
Use number arithmetic for the multipleOf LCM, with decimal counting that
understands exponent notation. When a scaled value or the LCM is outside
the safe integer range, fall back to the individual errors. Skip the LCM
when there is only one multipleOf.

Format message numbers with a plain FluentNumber instead of a custom
subclass. No translation uses NUMBER() or plural selection on these
values.

Move test coverage into the JSON test suite and remove the standalone
test files, along with tests for exact results outside the safe integer
range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jdesrosiers
jdesrosiers force-pushed the fix/289-multipleof-scientific-notation branch from 9e83c1f to c67ace0 Compare October 18, 2026 22:00

@jdesrosiers jdesrosiers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified the implementation because we know we won't have to deal with BigInts. I also moved tests to the JSON suite.

@jdesrosiers
jdesrosiers merged commit dfea9ce into hyperjump-io:main Oct 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: multipleOf error aggregation produces NaN for scientific-notation decimals

2 participants