Skip to content

fix(validation): multipleOf rejected valid fractional multiples - #272

Merged
idanci merged 1 commit into
mainfrom
idanci/fix-fractional-multipleOf
Sep 8, 2026
Merged

idanci merged 1 commit into
mainfrom
idanci/fix-fractional-multipleOf

Conversation

@idanci

@idanci idanci commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

multipleOf used a native remainder, which is unreliable for fractional divisors: 0.0001 has no exact binary representation, so 3.025 % 0.0001 yields 0.00009999999999976622 instead of 0 and the value is rejected.

Both operands are now scaled to whole numbers via their exact decimal parts and compared with a bigint remainder.
Integer operands keep the native remainder, which is already exact for them.

Fixes #222

multipleOf used a native remainder, which is unreliable for fractional
divisors: 0.0001 has no exact binary representation, so `3.025 % 0.0001`
yields 0.00009999999999976622 instead of 0 and the value is rejected.

Both operands are now scaled to whole numbers via their exact decimal
parts and compared with a bigint remainder. Integer operands keep the
native remainder, which is already exact for them.

Fixes #222
@sandrina-p
sandrina-p requested review from antoniocapelo and sandrina-p and removed request for antoniocapelo September 8, 2026 09:01
@idanci
idanci merged commit 89763fd into main Sep 8, 2026
5 checks passed
@idanci
idanci deleted the idanci/fix-fractional-multipleOf branch September 8, 2026 15:39
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.

multipleOf doesn't account for rounding errors

2 participants