Created
August 17, 2018 12:37
-
-
Save BukhariH/f52a9c4210f881310432926d834dc68a to your computer and use it in GitHub Desktop.
Checks if a BigDecimal is with in a tolerance value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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