Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!gatech!cuae2!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.lang.c Subject: Re: Any GOOD reason for C's behaviour in this example? Message-ID: <1085@ttrdc.UUCP> Date: Wed, 23-Jul-86 18:24:46 EDT Article-I.D.: ttrdc.1085 Posted: Wed Jul 23 18:24:46 1986 Date-Received: Thu, 24-Jul-86 21:14:19 EDT References: <1080@ttrdc.UUCP> Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 34 In article <1080@ttrdc.UUCP>, levy@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