conversion of short to unsigned it

Norman Diamond ndiamond at watdaisy.UUCP
Wed Mar 27 13:41:08 AEST 1985


>  The "(unsigned int)" is a cast, saying that s is to be
> considered unsigned rather than signed.  It is NOT a conversion.  The
> fact that s was declared to be a "short int" is immaterial; it is of
> type int rather than float, etc.  This has the same effect as saying
> "(unsigned)", without the "int".  Int has no inherent size associated
> with it; the size of an int is machine-dependent.  If you want an int
> of a specific size, you say "short int" or "long int".
> -- Ken Turkowski @ CADLINC, Menlo Park, CA

A cast had better do conversion.  Can you imagine (float) 3 being some
epsilon-ish sort of value?

Can you imagine      char *c;
                     int  *x;

                     x = (int *) c;

not converting from (char *) to (int *) ?  (This is irrelevant on machines
that use char * for all pointers.  If a machine uses byte offsets for char *
... such as calloc still is supposed to return ... and the assignment doesn't
CONVERT the result of calloc to int * ... then we might as well give up with C.)
-- 

   Norman Diamond

UUCP:  {decvax|utzoo|ihnp4|allegra}!watmath!watdaisy!ndiamond
CSNET: ndiamond%watdaisy at waterloo.csnet
ARPA:  ndiamond%watdaisy%waterloo.csnet at csnet-relay.arpa

"Opinions are those of the keyboard, and do not reflect on me or higher-ups."



More information about the Comp.lang.c mailing list