Created
September 16, 2021 20:10
-
-
Save ppazos/71dfe2ba04334f057a1aa867d672a24f to your computer and use it in GitHub Desktop.
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
BigDecimal.metaClass.round2 = { | |
def ctx = new java.math.MathContext(4) // doesnt work this is the total number of digits not the decimals | |
delegate.round(ctx) | |
} | |
def n = 2290.389649 | |
println n.round2() | |
println n.setScale(2, java.math.RoundingMode.HALF_UP) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment