Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site uiucdcs Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!mcewan From: mcewan@uiucdcs.CS.UIUC.EDU Newsgroups: net.micro Subject: Re: weird C behavior Message-ID: <10400217@uiucdcs> Date: Sun, 30-Mar-86 15:49:00 EST Article-I.D.: uiucdcs.10400217 Posted: Sun Mar 30 15:49:00 1986 Date-Received: Wed, 2-Apr-86 00:42:51 EST References: <557@utastro.UUCP> Lines: 42 Nf-ID: #R:utastro.UUCP:557:uiucdcs:10400217:000:1612 Nf-From: uiucdcs.CS.UIUC.EDU!mcewan Mar 30 14:49:00 1986 >> >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. Why? Are you saying that one should never have a function that accepts long arguments (or short, char, float, pointer, etc., for that matter)? > Changing the printf specification will n e v e r change what the > C compiler does with the rest of the arguments!! Never said it did. The constant "36864" is passed as a long no matter what string is used in the "printf" - the only difference is that with "%ld" printf correctly interprets and prints out the argument as a long. > 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. What is inconsistent about it? It is perfectly proper C. > However, an > arg has to be explicitly declared; so the int default almost has to > be honoured. I'm afraid I don't understand what you mean. Scott McEwan {ihnp4,pur-ee}!uiucdcs!mcewan Green s/m watchlizard seeks s/f/wl - object: companionship. Reply Box 23, Cynosure.