Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!.POSTED!not-for-mail From: Marco van de Voort Newsgroups: comp.lang.pascal.borland Subject: Re: longint and/or overflow bug? Date: Wed, 31 Oct 2012 09:35:02 +0000 (UTC) Organization: Stack Usenet News Service Lines: 22 Message-ID: References: NNTP-Posting-Host: toad.stack.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: mud.stack.nl 1351676102 67113 2001:610:1108:5010::135 (31 Oct 2012 09:35:02 GMT) X-Complaints-To: abuse@stack.nl NNTP-Posting-Date: Wed, 31 Oct 2012 09:35:02 +0000 (UTC) User-Agent: slrn/0.9.9p1 (FreeBSD) Xref: csiph.com comp.lang.pascal.borland:132 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).