home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,895 of 2,978   
   Marco van de Voort to Jim Leonard   
   Re: longint and/or overflow bug?   
   31 Oct 12 09:35:02   
   
   e1050251   
   From: marcov@toad.stack.nl   
      
   On 2012-10-30, Jim Leonard  wrote:   
   >   
   > var   
   >   l:longint;   
   >   w1,w2:word;   
   >   
   > begin   
   >   w1:=val1; w2:=val2;   
   >   l:=w1 * w2; {Throws runtime 215 "arithmetic overflow" if $Q+}   
      
   typing:   
   longint :=word * word   
      
   Pascal rule is afaik that an expression is evaluated in (at least?) the   
   combined range of the operands.  Which is word.   
      
   So the above translates to   
      
   tempresult: word = word * word   
   longint:=convert(word,longint,tempresult);   
      
   Note that FPC/Delphi do the same with 64-bit results (in 32-bit mode).   
      
   --- 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