Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!hao.ucar.edu!murphy From: murphy@hao.ucar.edu (Graham Murphy) Newsgroups: comp.sys.mac.programmer Subject: Think C 4.0 comparison problem Keywords: things int as I'd like it Message-ID: <6097@ncar.ucar.edu> Date: 24 Jan 90 06:26:17 GMT Sender: news@ncar.ucar.edu Reply-To: murphy@hao.ucar.edu (Graham Murphy) Followup-To: murphy@hao.ucar.edu Organization: High Altitude Observatory/NCAR, Boulder CO Lines: 27 I have found that with C code such as: main() { long int minus1 = -1 ; unsigned int one = 1 ; if( one < minus1 ) printf( "This gets printed\n" ) ; } the printf is executed. It should _not_ be according to my source of the ANSI standard conversions [1]. The unsigned int should always be converted to long int for the comparison as the latter can hold all the values of the former on a Mac. This would preserve the concept that 1 is greater than -1! Anyone know what the problem is and any work-arounds? Graham Murphy [1]: ANSI C: A Lexical Guide 1988, Mark Williams Company (New Jersey:Prentice-Hall). High Altitude Observatory National Center for Atmospheric Research P.O. Box 3000, Boulder CO 80307-3000. Ph:(303)497-1565; Fax:(303)497-1137. INTERNET: murphy@hao.UCAR.EDU; Solar PO: gmurphy@solar.STANFORD.EDU