Path: utzoo!attcan!uunet!cs.utexas.edu!yale!eagle!rcook From: rcook@eagle.wesleyan.edu Newsgroups: comp.sys.mac.programmer Subject: THINK Pascal expression quirk Message-ID: <16954@eagle.wesleyan.edu> Date: 12 Apr 90 11:17:17 GMT Lines: 29 So this is what I had going on in THINK Pascal 2.0: var x, a, b : integer; begin .. a := 400; b := 500; x := 11 + round( 248 * a / b ); .. end; x was computed to be a negative number! Do you see any minus signs above? I figured the '/' operator would force the whole expression inside round() to evaluate as floating point numbers, but I suspect the compiler saw that '248*a' was composed entirely of integers and computed an integer product, which overflowed the range of an integer (though I didn't notice since I had range checking off). I changed the 248 to 248.0 and everything worked fine. Big deal? Indeed, I should be using fixed point math anyway... The next day I got THINK Pascal 3.0 and have not checked whether it has the same quirk. I just thought someone might be interested. Beats drivel about upgrade prices though :-) Randall Cook rcook@eagle.wesleyan.edu