Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c,net.micro,net.micro.pc Subject: Re: weird C behavior Message-ID: <559@umcp-cs.UUCP> Date: Wed, 26-Mar-86 21:43:39 EST Article-I.D.: umcp-cs.559 Posted: Wed Mar 26 21:43:39 1986 Date-Received: Sun, 20-Apr-86 07:42:38 EST References: <557@utastro.UUCP> <436@umcp-cs.UUCP> <330@hadron.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 39 Keywords: strange, opaque, odd In article <330@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes: >>On a 16 bit machine, this should read >> printf("%ld\n", 36864); [me] >Passed arguments should always be passed as an "int", I do believe. >... Sorry to have to publicly disagree, Chris. Unfortunately for you, I checked my sources first. The clue was there in Ed's original posting. According to K&R, a constant that is too big to be an `int' is automatically considered a `long'; on a 16 bit machine, printf("%ld\n", 36864); and printf("%ld\n", 36864L); build the exact same stack. For you ANSI C buffs, I quote from a year-old draft (the latest I could find), section C.1.3.2, `Integer constants': If the value of an unsuffixed decimal constant (base 10) is no greater than that of the largest signed int, the constant has type signed int; otherwise it has type signed long int. Now, if you were using ANSI C and had written, say, void myfunc(int); myfunc(36864); you would get something closer to what you expected. . . . -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu