Possible C compiler bug on 8086 machines
Andrew Koenig
ark at alice.att.com
Mon Jan 14 05:06:21 AEST 1991
In article <3577 at bruce.cs.monash.OZ.AU> alanf at bruce.cs.monash.OZ.AU (Alan Grant Finlay) writes:
> printf("This doesn't work : %d, %d\n",65536/512,512);
> This doesn't work : 128, 0
> Is this a problem with my machine or the printf routine?
It's probably a bug in your program.
If your compiler stores ints in 16 bits, then 65536 is a long
and 65536/512 is also a long. You should therefore do one of the
following:
printf("This should work : %d, %d\n", (int)(65536/512), 512);
printf("This might also work : %ld, %d\n", 65536/512, 512);
--
--Andrew Koenig
ark at europa.att.com
More information about the Comp.lang.c
mailing list