Skip to content

Instantly share code, notes, and snippets.

@richardwooding
Created September 29, 2015 13:44
Show Gist options
  • Save richardwooding/50e51926be7f0fa76d6f to your computer and use it in GitHub Desktop.
Save richardwooding/50e51926be7f0fa76d6f to your computer and use it in GitHub Desktop.
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