...
Code Block | ||
---|---|---|
| ||
int i = 1; String s = Double.valueOf (i / 1000.0).toString(); // s contains 0.0010 if(s.equals("0.001")) { // Fails // Do something } |
...
Code Block | ||
---|---|---|
| ||
int i = 1; BigDecimal d = new BigDecimal(Double.valueOf (i / 1000.0).toString()).stripTrailingZeros(); if(s.equals(d.compareTo(new BigDecimal("0.001")) == 0) { // Passes // Do something } |
...