
Originally Posted by
Merri
VB appears to go for the smallest datatype after math:
Code:
&HFFFF0000 \ &H10000
Result? Integer -1
Merri, I got a Long return type. When doing straight math (no conversion functions used, ie, CInt, etc), I believe VB will return the value as the VarType of the largest VarType used in the calculation.
To test my idea, I used the following
Code:
? (VarType(&HFFFF0000 \ &H10000)=vbLong)
' ^^ 2 longs
? (VarType(&HFFFF0000 \ &H100)=vbLong)
' ^^ 1 long, 1 vb integer (2 bytes)
Edited: Not true? What logic VB uses is anyone's guess. Take a look at this:
Code:
? (VarType(&HFFFF * 1#)=vbDouble), (VarType(&HFFFF \ 1#)=vbLong)
' 1st calc: Int * Double = Double
' 2nd calc: Int \ Double = Long
' ^^ I expected Integer since Int division used & numerator is Int,
' but maybe VB is converting Double to Long because of Int division?