Skip to content

Instantly share code, notes, and snippets.

View richardwooding's full-sized avatar

Richard Wooding richardwooding

View GitHub Profile
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
@richardwooding
richardwooding / testbigdecimalmax.groovy
Last active September 29, 2015 13:50
Testing BigDecimal with Math.max versus BigDecimal.max
#!/usr/bin/env groovy
// Math.min and Math.max are dangerous with BigDecimal due to loss of precision when converting to float
// We should be using BigDecimal.min and BigDecimal.max instead
// Proof
BigDecimal a = new BigDecimal('6270.30')
BigDecimal b = new BigDecimal('6270.30')
//Safe
Verifying that +richardwooding is my blockchain ID. https://onename.com/richardwooding