Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!mips!apple!tahoe!rfh From: rfh@tahoe.unr.edu (Randy F. Hall) Newsgroups: comp.lang.pascal Subject: HELP with Turbo Pascal problem Keywords: Turbo Pascal Message-ID: <3433@tahoe.unr.edu> Date: 6 Jan 90 02:44:25 GMT Reply-To: rfh@unssun.nevada.edu (J.A. MacDonald) Organization: University of Nevada, Reno Lines: 44 HELP!! I wrote the following program in TurboPascal 5.5 and got a very wrong answer. One would expect to get an output value for j of 64516, but instead get -1020. The only explanation I could think of was that there is a screw up in the 2's compliment or something. I also tried running it through TP5.0 and on other machines, but with the same result. It has the same problem whether j is defined as a LONGINT or REAL. Also for i = 255, -255 and -254. I haven't tested for any other values. Replacing i * i with SQR (i) didn't help either. ------------------------- Program test; Var i : integer; j : real; begin i := 254; j := i * i; Writeln (j); Readln; end. ------------------------- If anybody has any idea what may be the problem, let me know. I can get around the trouble (fortunately) by using WORD declaration for j as j will never get above 65535. In the future this may be a problem though. Thanks in advance JaM real BMW's have only two wheels ============================================================================= rfh@unssun.nevada.edu | I lit out from Reno | I was trailed by twenty hounds... =============================================================================