Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!chaos.cs.brandeis.edu!chaos!phils From: phils@chaos.cs.brandeis.edu (Phil Shapiro) Newsgroups: comp.sys.mac.programmer Subject: Re: THINK Pascal expression quirk Message-ID: Date: 12 Apr 90 22:13:04 GMT References: <16954@eagle.wesleyan.edu> Sender: @chaos.cs.brandeis.edu Organization: Brandeis University Computer Science Dept Lines: 10 In-Reply-To: rcook@eagle.wesleyan.edu's message of 12 Apr 90 11:17:17 GMT If you don't put on overflow checking (the V flag in the project menu, or {$V+} in your program) then THINK Pascal will happily overflow your integers into their sign bits. The compiler parses the operators '*' and '/' (which have the same precedence) from left to right, so it compiled the multiply operation before the divide. You could promote one of the operands into a longint; this will prevent the integer overflow. -- Phil Shapiro phils@chaos.cs.brandeis.edu