Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watdaisy.UUCP Path: utzoo!watmath!watdaisy!ndiamond From: ndiamond@watdaisy.UUCP (Norman Diamond) Newsgroups: net.lang.c Subject: Re: conversion of short to unsigned it Message-ID: <7110@watdaisy.UUCP> Date: Fri, 22-Mar-85 13:08:34 EST Article-I.D.: watdaisy.7110 Posted: Fri Mar 22 13:08:34 1985 Date-Received: Sat, 23-Mar-85 01:43:24 EST References: <2125@ncrcae.UUCP> <7088@watdaisy.UUCP> <2128@ncrcae.UUCP> Organization: U of Waterloo, Ontario Lines: 29 > unsinged int ui; > unsigned short us; > short s; > > s = -3; > us = -3; > ui = s; > > if ((unsigned int)s == us) printf("OOPS\n"); > > prints OOPS meaning that fffffffd == 0000fffd !!! It could mean 0000fffd == 0000fffd. If (unsigned int) s is sometimes equivalent to (unsigned int) (int) s, but other times equivalent to (unsigned int) (unsigned short) s, then I don't think any rule is being violated. A compiler does not have to be consistent in its treatment of ambiguous constructs. (In fact, inconsistency should be encouraged because it quickens the discovery of bugs.) -- Norman Diamond UUCP: {decvax|utzoo|ihnp4|allegra}!watmath!watdaisy!ndiamond CSNET: ndiamond%watdaisy@waterloo.csnet ARPA: ndiamond%watdaisy%waterloo.csnet@csnet-relay.arpa "Opinions are those of the keyboard, and do not reflect on me or higher-ups."