Created
December 9, 2020 09:51
-
-
Save omidp/be1c97865be8408066c0dd2a51d783f9 to your computer and use it in GitHub Desktop.
bd precision
This file contains hidden or 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
public BigDecimal multiply() | |
{ | |
try | |
{ | |
return new BigDecimal(new DecimalFormat("#.##").format(n1.multiply(n2))); | |
} | |
catch (ArithmeticException se) | |
{ | |
MathContext mc = new MathContext(2, RoundingMode.HALF_UP); | |
return n1.multiply(n2, mc); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment