Red Hat Bugzilla – Bug 855871
Imprecise number results in Pet Store example
Last modified: 2013-01-10 20:36:17 EST
Description of problem:
Pet store example application should present the use of Drools in business world and every ordinary calculator is able to calculate 90 or 95 percent of some number exactly. Hence, it is not a good advertisement if Drools are presenting results in form of 18.900000000000002 or 11.399999999999999 in case that these numbers should be exact 18.9 and 11.4.
Version-Release number of selected component (if applicable):
Follow next steps.
Steps to Reproduce:
1. Run examples by runExamples.sh script and then start PetStoreExample.
2. Click 2x on "Gold Fish" and 1x on "Fish Food" and press "Checkout" and "Yes"
3. You will get discounted total 11.399999999999999
4. Press "Reset" button
5. Press 3x on "Gold Fish" and 3x on "Fish Food" and press "Checkout" and "Yes"
6. You will get discounted total 18.900000000000002
Imprecise results (11.399999999999999 and 18.900000000000002)
Mathematically exact results (11.4 and 18.9)
I suppose that this is a problem of type double and rather BigDecimal should be used .