Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site utastro.UUCP Path: utzoo!linus!decvax!ittatc!dcdwest!sdcsvax!ncr-sd!hp-sdd!hplabs!qantel!lll-lcc!lll-crg!mordor!ut-sally!utastro!nather From: nather@utastro.UUCP (Ed Nather) Newsgroups: net.lang.c,net.micro,net.micro.pc Subject: weird C behavior Message-ID: <557@utastro.UUCP> Date: Fri, 21-Mar-86 13:29:55 EST Article-I.D.: utastro.557 Posted: Fri Mar 21 13:29:55 1986 Date-Received: Mon, 31-Mar-86 06:07:04 EST Organization: U. Texas, Astronomy, Austin, TX Lines: 35 Keywords: strange, opaque, odd Xref: linus net.lang.c:7644 net.micro:12873 net.micro.pc:7244 Here is a short C program which gives correct output according to K & R. While I can't argue it's wrong, it is not transparently right, either. The following was extracted directly from the display screen of my IBM PC. Try it on *your* 16-bit computer. Then explain it to a friend. ----------------------------------------------------------------------- C% print weird.c /* weird.c - demonstrate weird C behavior */ /* Reference: Kernighan and Ritchie pp. 40-41 */ #include #define BIG 36864 main() { int i; i = BIG; if(i == BIG) printf("Equality found: i = %d, BIG = %d\n", i, BIG); else printf("Equality NOT found: i = %d, BIG = %d\n", i, BIG); } C% weird Equality NOT found: i = -28672, BIG = -28672 ----------------------------------------------------------------------- -- Ed Nather Astronomy Dept, U of Texas @ Austin {allegra,ihnp4}!{noao,ut-sally}!utastro!nather nather@astro.UTEXAS.EDU