Results 1 to 18 of 18

Thread: [RESOLVED] Interesting: 65535 and &HFFFF

Threaded View

  1. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Interesting: 65535 and &HFFFF

    Quote 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?
    Last edited by LaVolpe; Dec 14th, 2007 at 12:35 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width