Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!orsvax1!pyrnj!caip!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c,net.micro,net.micro.pc Subject: Re: weird C behavior Message-ID: <330@hadron.UUCP> Date: Sun, 23-Mar-86 13:34:23 EST Article-I.D.: hadron.330 Posted: Sun Mar 23 13:34:23 1986 Date-Received: Fri, 28-Mar-86 04:59:04 EST References: <557@utastro.UUCP> <436@umcp-cs.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 26 Keywords: strange, opaque, odd Xref: watmath net.lang.c:8279 net.micro:14141 net.micro.pc:7551 Summary: Aren't constants and args int unless otherwise declared? In article <436@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes: >In article <557@utastro.UUCP> nather@utastro.UUCP (Ed Nather) writes: >>Here is a short C program which gives correct output according to K & R. >>[...] Try it on *your* 16-bit computer. >The code contains the following [paraphrased]: > printf("%d\n", 36864); >On a 16 bit machine, this should read > printf("%ld\n", 36864); >One alternative is to change Ed's original program to read > #define BIG ((int) 36864) Passed arguments should always be passed as an "int", I do believe. Changing the printf specification will n e v e r change what the C compiler does with the rest of the arguments!! Nather's original posting led me to believe he was using some kind of a 16/32 bit machine, with a C compiler that had not quite been consistent. I.e., on the comparison, all I could think was that a 16-bit int had sign- extended to compare with an IMPLICIT long constant (look at it: it's not an explicit long constant!). This is inconsistent. However, an arg has to be explicitly declared; so the int default almost has to be honoured. Sorry to have to publicly disagree, Chris. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}