Array of Doubles loses precision

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

Seems to be a bug in the debugger… because if you display arr(0) it is correct

And here I was thinking the debugger would know what it was talking about :wink: Thanks Dave it looks like my bug must be elsewhere then … back to the bug hunt I go. If someone can file a feedback case that would be great, or I can file one in a while when I have the free time.

To show it the debugger has to convert it to a string and that conversion is likely the issue.