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
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 |
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
#!/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 |
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
Verifying that +richardwooding is my blockchain ID. https://onename.com/richardwooding |
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
gist |