WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE COM ADO CDO ADSI LDAP
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

VT_DECIMAL Versus FLOAT

 Keywords: Float Floating Point Decimal VT_DECIMAL Compare Calculate 

Question:

I hit something that caught me out today. I had a subroutine doing an ADO lookup on an access DB table and returning a value from a record which is a decimal. The data type in WB is VT DECIMAL and the actual value was 0.712006. IF you compared the variable to zero the result was true !! I had to add 0.0 to the value to make it a float and then the compare to zero worked.

Answer:

Yes, this is expected behavior. You were comparing two different datatypes. When attempting to compare data types, you want to make sure they are both floating point. So your solution of adding 0.0 solved the problem because, adding 0.0 causes the VT_DECIMAL to convert to a true floating point datatype.

The VT_DECIMAL variants representation is dictated by MSFT's COM implementation and is NOT internally the same as a floating point number's representation. VT_DECIMAL values have a much different range, precision, and representational error possibility. Because of this, there's no way to convert a VT_DECIMAL to a floating point number and guarantee the validity so WinBatch doesn't automatically convert a VT_DECIMAL to a number unless you force the issue. In fact, WinBatch treats VT_DECIMALs as strings unless forced to do otherwise.


Article ID:   W18026
Filename:   VT_DECIMAL Versus FLOAT .txt
File Created: 2010:12:03:14:05:30
Last Updated: 2010:12:03:14:05:30