Disclaimer: I’m familiar with IEEE 754 floating point numbers and know that they have signed zeroes and other special values. That is not the question. If you enjoy language lawyering, read on.
We found a curious behavioral difference between 32 bit and 64 bit VBA:
' 32 bit VBA
? CStr(0.0 * -1)
0
' 64 bit VBA
? CStr(0.0 * -1)
-0
Apparently, the string representation of negative zero of (both single and double) floating point numbers is different in 32 bit and 64 bit VBA.
Section 5.5.1.2.4 of the VBA specification mentions that zero is converted to the string "0"
, so depending on whether you interpret (unqualified) “zero” as “positive zero” or “positive or negative zero”, this could be seen as a spec violation.
Is this issue documented somewhere? Are there other floating point discrepancies between 32 and 64 bit VBA that we should be aware of?
Notes:
- We were able to reproduce this with Office 2016 and Microsoft 365, but I doubt that the exact version matters.
- I have tagged this question with both MS Access and MS Excel, since those are the two main “users” of VBA.