Skip to content

Commit 2273b37

Browse files
ubergrohmanSergey Dudorov
and
Sergey Dudorov
authored
Fixed loss of accuracy (#422)
Co-authored-by: Sergey Dudorov <[email protected]>
1 parent afb72f0 commit 2273b37

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/com/networknt/schema/MultipleOfValidator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
4646
double nodeValue = node.doubleValue();
4747
if (divisor != 0) {
4848
// convert to BigDecimal since double type is not accurate enough to do the division and multiple
49-
BigDecimal accurateDividend = new BigDecimal(String.valueOf(nodeValue));
49+
BigDecimal accurateDividend = node.isBigDecimal() ? node.decimalValue() : new BigDecimal(String.valueOf(nodeValue));
5050
BigDecimal accurateDivisor = new BigDecimal(String.valueOf(divisor));
5151
if (accurateDividend.divideAndRemainder(accurateDivisor)[1].abs().compareTo(BigDecimal.ZERO) > 0) {
5252
return Collections.singleton(buildValidationMessage(at, "" + divisor));

0 commit comments

Comments
 (0)