Any GOOD reason for C's behaviour in this example?
Daniel R. Levy
levy at ttrdc.UUCP
Thu Jul 24 08:24:46 AEST 1986
In article <1080 at ttrdc.UUCP>, levy at ttrdc.UUCP (yeah, that's me) writes:
>main()
>{
> unsigned short a, b;
> int i;
> a=4;
> b=5;
> i = ( (int) a) - ( (int) b);
> (void) printf("%d\n",i);
> return 0;
>}
>
>(The machine being used was a 3B2, which
>has two-byte unsigned shorts and four-byte ints.)
>
>However, I initially did a double take when I found that code such as
>exemplified in this little program produces a result exemplified by:
>
>65535
Whoops, whoops, and triple whoops. I got my accounts confused. It works
as expected on the 3B2 (outputs a value of -1). It was a _3B20_ which
tripped up on this one! (BTW I have received mail from a person on attunix
telling me that the CURRENT 3B20 compiler has this bug fixed. I guess I
need to get an update.) So much for flames... **SPLOOSH** Oy vey.
SORRY!!!!!!!!!!
--
------------------------------- Disclaimer: The views contained herein are
| dan levy | yvel nad | my own and are not at all those of my em-
| an engihacker @ | ployer or the administrator of any computer
| at&t computer systems division | upon which I may hack.
| skokie, illinois |
-------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
go for it! allegra,ulysses,vax135}!ttrdc!levy
More information about the Comp.lang.c
mailing list