A Big Decimal Accumulator for Drools
Working in the financial industry, I have become rather strict about avoiding doubles in Java. The trouble is that they are a floating point representation of a number, which is just an approximation of the real value. This can lead to some unusual results.
For instance, according to this, 0.34 + 0.01 is not equal to 0.35.
double x = 0.35; double y = 0.34 + 0.01; System.out.println(x + " : " + y + " : " + (x == y)); 0.35 : 0.35000000000000003 : false Those inaccuracies might seem very small, but it’s surprisingly easy for them to start impacting a real world application. Imagine you wanted to sell dollars and buy Iranian Rial. You would be getting almost 20,000 Rial for every dollar. At that rate, imprecise floating point values could easily impact the final amount being sent. Although with the current US trade sanctions against Iran, that could be the least of your problems.
...