Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,736 of 10,840    |
|    Raoul Watson to Henning    |
|    Re: VB math prob    |
|    09 Nov 05 03:09:12    |
   
   From: WatsonR@IntelligenCIA.com   
      
   "Henning" wrote in message   
   news:436fdee6$0$98292$57c3e1d3@news3.bahnhof.se...   
   > Hi grp   
   > What the ... is this. Have I missed something?   
   >   
   > Dim x as Long   
   >   
   > x = 192 * 256 '** overflow error ???   
   >   
   > x = &HC000 '** works ok   
   >   
   > The value is the same in both cases.   
   >   
      
   No they are not the same. Had you done x = 49152 it would have worked as   
   well.   
      
   The problem is not the target (x as long) but rather an intermediary result.   
      
   Unless specified, the intermediate result in VB will be INT and as we all   
   know it, anything greater than 32767 would exceed int limit.   
      
   So, this will generate an error   
      
   dim a as integer   
   dim b as integer   
   dim x as long   
   a = 192   
   b = 256   
   x = a * b   
      
   Whereas this will not   
   dim a as long   
   dim b as long   
   dim x as long   
   a = 192   
   b = 256   
   x = a * b   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca