3 ms·
Using doubles in Java you get 0.199999..8, using BigDecimal you get the correct 0.2. jshell> new BigDecimal("0.3").subtract(new BigDecimal("0.1")) $8 =
by vips7L 6y ago
Using doubles in Java you get 0.199999..8, using BigDecimal you get the correct 0.2.
jshell> new BigDecimal("0.3").subtract(new BigDecimal("0.1"))
$8 ==> 0.2
- qsort 6y agoYeah, and using float literals you get 0.20000...2: jshell> .3f-.1f $1 ==> 0.20000002 We got ourselves a hat trick :)