Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Checks if a BigDecimal is with in a tolerance value
private static boolean isWithinTolerance(BigDecimal amount, BigDecimal tolerance) {
return (amount.compareTo(tolerance.negate()) > 0 && amount.compareTo(tolerance) < 0)
|| amount.abs().compareTo(tolerance) == 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.