Skip to content

Commit

Permalink
Merge pull request #4802 from romanbsd/fix-precision
Browse files Browse the repository at this point in the history
Change MathContext to 64, as 32 is not enough for some coins
  • Loading branch information
timmolter authored Apr 20, 2024
2 parents d84d219 + 33f9174 commit 7dd2e5c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static BigDecimal roundToStepSize(BigDecimal value, BigDecimal stepSize)

public static BigDecimal roundToStepSize(
BigDecimal value, BigDecimal stepSize, RoundingMode roundingMode) {
BigDecimal divided = value.divide(stepSize, MathContext.DECIMAL32).setScale(0, roundingMode);
return divided.multiply(stepSize, MathContext.DECIMAL32).stripTrailingZeros();
BigDecimal divided = value.divide(stepSize, MathContext.DECIMAL64).setScale(0, roundingMode);
return divided.multiply(stepSize, MathContext.DECIMAL64).stripTrailingZeros();
}
}

0 comments on commit 7dd2e5c

Please sign in to comment.