Skip to content

Commit 4799ac4

Browse files
authoredApr 18, 2025
Use decimal in multipleOf for the issue of accuracy
1 parent 128efb1 commit 4799ac4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎jsonschema/_keywords.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from decimal import Decimal
12
from fractions import Fraction
23
import re
34

@@ -169,7 +170,7 @@ def multipleOf(validator, dB, instance, schema):
169170
return
170171

171172
if isinstance(dB, float):
172-
quotient = instance / dB
173+
quotient = Decimal(str(instance)) / Decimal(str(dB))
173174
try:
174175
failed = int(quotient) != quotient
175176
except OverflowError:

0 commit comments

Comments
 (0)
Failed to load comments.