Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!ogicse!zephyr.ens.tek.com!tekgen!penguin.uss.tek.com!decomyn From: decomyn@penguin.uss.tek.com Newsgroups: comp.lang.pascal Subject: Re: Help Me!!! What's wrong with this simple problem? Message-ID: <6936@tekgen.BV.TEK.COM> Date: 28 Nov 90 16:40:33 GMT References: <527@shum.UUCP> <19956@oolong.la.locus.com> <28893@shamash.cdc.com> Sender: news@tekgen.BV.TEK.COM Reply-To: decomyn@penguin.uss.tek.com (Vergil William de Comyn) Organization: Tektronix, Inc., Beaverton, OR. Lines: 36 In article <28893@shamash.cdc.com> mpe@shamash.UUCP (Mike Ebsen) writes: >What's wrong with this problem in Turbo Pascal 5.0... > > Program test; > var > i : integer; > j : word; > begin > j:=3; > i:=j-10; > writeln(j,' ',i); > end. > >My compiler tells me that the assignment of -7 into i (an integer) >is an error. Looks like a minor TP bug. What appears (to me) to be happening is that the internal representation of j-10 is being treated as arithmetic on a word value. Since -7 is an illegal value for a word variable, the resulting code is returning an error (you didn't say exactly what error code TP was giving you, so this is just a guess.) Try typecasting j into an integer... (blast, my references are at home. I *think* you can do that by entering the following: i:=integer(j)-10; in place of the line giving you the error, but I'm not certain.) Good Luck ------------------------------------------------------------------------------- Brendt Hess a.k.a. | Disclaimer: Opinions? I don't even work here! Vergil William de Comyn a.k.a. |----------------------------------------------- Payne Hirds | Life is not a zero-sum game: decomyn@penguin.uss.tek.com | don't treat it as such.