How is numeric data stored in variant data types? It seems that numbers in variant data types don't respond well to high-precision calculations. I had the calculation (data types as in the names):
and I had a case when:
But dblX returned 0, not -0.0000000121.
In fact, I did some testing in the immediate window and trucated a few of the first zeros. Only when I got to 0.000121 was dblZ set to -0.0001.
When I apply CDbl() to varY, things are fixed. It seems odd that variants can hold doubles just fine, but don't return as double unless forced.
Is this behaviour normal?
Thanks
Code:
dblX = varY - dblZ
Code:
varY = 0
dblZ = 0.0000000121
In fact, I did some testing in the immediate window and trucated a few of the first zeros. Only when I got to 0.000121 was dblZ set to -0.0001.
When I apply CDbl() to varY, things are fixed. It seems odd that variants can hold doubles just fine, but don't return as double unless forced.
Is this behaviour normal?
Thanks
Last edited: