Path: utzoo!utgpu!news-server.csri.toronto.edu!qucdn!spraggej Organization: Queen's University at Kingston Date: Wednesday, 28 Nov 1990 09:27:37 EST From: John G. Spragge Message-ID: <90332.092737SPRAGGEJ@QUCDN.QueensU.CA> Newsgroups: comp.lang.pascal Subject: Re: Help Me!!! What's wrong with this simple problem? References: <527@shum.UUCP> <19956@oolong.la.locus.com> <28893@shamash.cdc.com> In article <28893@shamash.cdc.com>, mpe@shamash.cdc.com (Mike Ebsen) says: > >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. The expression j-10 is evaluated as a word expression. The result of subtracting 10 from 3 in a word will not be -7, since the word is unsigned: it is 65536-7, or 65529. Since integers only range from -32768 to 32767, the compiler detects an error.