Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: Notesfiles $Revision: 1.7.0.8 $; site ndm20
Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!convex!ndm20!tp
From: tp@ndm20
Newsgroups: net.lang.c
Subject: Re: Uses of "short" ?
Message-ID: <3400008@ndm20>
Date: Wed, 18-Sep-85 10:24:00 EDT
Article-I.D.: ndm20.3400008
Posted: Wed Sep 18 10:24:00 1985
Date-Received: Sun, 29-Sep-85 04:46:24 EDT
References: <486@houxh.UUCP>
Lines: 32
Nf-ID: #R:houxh.UUCP:-48600:ndm20:3400008:000:1643
Nf-From: ndm20!tp    Sep 18 09:24:00 1985


>I doubt we disagree fundamentally; I just think you are stating the case too
>strongly.  My goal is to introduce environment dependencies only as needed.
>I nevertheless believe, for instance, that when Internet protocol specifies
>that the header checksum is a 16-bit 2's-complement number, it is wise to
>comply, if you want the packets to fly properly.

But what type is that in C.  On a Harris H-series machine, a short is
24 bits, as is an int.  A long is  48 bits.   Obviously  this kind of
code is machine dependent.  I believe that the point Guy is trying to
make is that you CAN NOT assume that  a short  is 16  bits on *every*
machine, because it isn't, so you should recognize that  what you are
doing is machine dependent, no matter HOW you code it  in C.   If the
exact number of bits is mandated, it is a machine dependence how that
will be handled.  If it is not, then we should deal with abstractions
to produce more portable code.  

I always use the guideline that if a number is  less than  16K, I use
short, and if it is known to be greater than that I use long.  If the
range of values is not well known, or space efficiency is not a great
concern, I use int, as that is presumably the  most efficient integer
type.  These aren't the best guidelines in the  world, and  I am open
to better suggestions.   It  would be  nice to  be able  to declare a
value  range  and  let the  compiler pick  the type  based on machine
characteristics (a la Pascal).

Terry Poot
Nathan D. Maier Consulting Engineers
(214)739-4741
Usenet: ...!{allegra|ihnp4}!convex!smu!ndm20!tp
CSNET:  ndm20!tp@smu
ARPA:   ndm20!tp%smu@csnet-relay.ARPA