Created
September 29, 2015 13:44
-
-
Save richardwooding/50e51926be7f0fa76d6f 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
import java.math.BigDecimal; | |
public class BigDecimalMaxTest { | |
public static void main(String ... args) { | |
BigDecimal a = new BigDecimal("6270.30"); | |
BigDecimal b = new BigDecimal("6270.30"); | |
//Safe | |
BigDecimal c = a.max(b); | |
//Unsafe | |
BigDecimal d = new BigDecimal(Math.max(a.doubleValue(), b.doubleValue())); | |
System.out.printf("A: %s B: %s C: %s, D: %s\n", a, b, c, d); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment