Xref: utzoo comp.lang.c:35973 comp.os.msdos.programmer:3253 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!n8emr!bluemoon!bytehead From: bytehead@bluemoon.uucp (Bryan Price) Newsgroups: comp.lang.c,comp.os.msdos.programmer Subject: Re: Possible C compiler bug on 8086 machines Message-ID: Date: 8 Feb 91 19:57:40 GMT References: <3577@bruce.cs.monash.OZ.AU> Sender: bbs@bluemoon.uucp (BBS Login) Organization: Blue Moon BBS ((614) 868-9980/2/4) Lines: 34 alanf@bruce.cs.monash.OZ.AU (Alan Grant Finlay) writes: > > -----------------------------//--------------------------- > > #include > > main() > { > int x,y; > x = 65536/512; // You just assigned a long int to a short int here > y = 512; > printf("This works : %d, %d\n",x,y); > printf("This doesn't work : %d, %d\n",65536/512,512); // Buzzzzt! The first %d should be a %ld, since you are // passing a long int (not a short int) for the 1st numeric // parameter. 65536 is a long, and forces the compiler to // pass it as a long, even if it fits in a short int. > } > > ----------------------------//------------------------------ > > And here is a sample output: > > This works : 128, 512 > This doesn't work : 128, 0 > > Does anyone have any idea why? > Is this a problem with my machine or the printf routine? This is a problem with your mind. #include <.sig>