After searching through my code for several hours to track down a bug, I have found that the bug is due to the fact that doubles seem to lose precision when they are stuffed into arrays. Take the following code as an example: (The numbers are part of the test data which uncovered the bug in my code)
dim a as Double = 50.0
dim b as Double = 2519.0
dim aOverB as Double = a/b
dim tmpDbl as Double = aOverB
dim arr() as Double
arr.Append aOverB
Break
When the debugger breaks, I expect to see that aOverB = 0.0198491464867011, tmpDbl = 0.0198491464867011, and arr() contains a single element with a value of 0.0198491464867011. Upon inspection, however, arr() contains a single element with a value of 0.02, rounding the value of aOverB. Repeating with many other test values, arr() will always contain a rounded value (in some cases small decimals are rounded to 0.0, making any further calculations invalid), which is a problem since my program is statistics software and needs as many places of precision as possible. Is this a bug in Xojo or an intended feature? If its a feature can someone explain the rationale and any work arounds? Thanks