Ok, JavaSE 1.8 running an application in Eclipse Version: Oxygen.3a Release (4.7.3a) Build id: 20180405-1200. Simple arithmetic:
Double dblBalance; ( showing as 2072.41 in debug, but also running the app in the IDE)
Double dblAmountofAllocation; ( showing as 1900.0 at runtime )
dblBalance = dblBalance - dblAmountofAllocation; ( dblBalance shows 172.40999995 at runtime)
( my workaround - shouldn't be necessary)
dblBalance = Math.round(dblBalance * 100.0) / 100.0;
I have also tested this in a test case compiled and run from the command line. So it is reproducible. Is it the Java runtime engine?
very puzzled - I would like to know if this can be replicated by others. Most combinations of Double values don't have this problem - do I need to stick with the native data types?