Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!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: <614@umcp-cs.UUCP> Date: Sat, 29-Mar-86 18:32:09 EST Article-I.D.: umcp-cs.614 Posted: Sat Mar 29 18:32:09 1986 Date-Received: Sun, 30-Mar-86 10:51:11 EST References: <557@utastro.UUCP> <436@umcp-cs.UUCP> <2194@watdcsu.UUCP> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 25 Xref: watmath net.lang.c:8307 net.micro:14166 net.micro.pc:7579 In article <2194@watdcsu.UUCP> broehl@watdcsu.UUCP (Bernie Roehl) writes: >In article <436@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes: >>On a 16 bit machine, this should read >> >> printf("%ld\n", 36864); [me] > >Both are wrong on a 16 bit machine, and both will produce garbage (though >probably different garbage). False. I have already explained why, with references to K&R and an old X3J11 draft. >What you want is > > printf("%ld\n", 36864L); [Bernie] I agree that this is considerably better in practice. In fact, I would not at all mind a compiler that gave warnings whenever an unsuffixed constant did not fit in an integer and was promoted to long (or unsigned long for `U' suffixed and hex and octal constants, per X3J11). -- 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