1 <!DOCTYPE HTML PUBLIC
"-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995-7 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
7 <link rev=
"owner" href=
"mailto:scs@eskimo.com">
8 <link rev=
"made" href=
"mailto:scs@eskimo.com">
9 <title>18.1.2:
<TT>short int
</TT></title>
10 <link href=
"sx4aa.html" rev=precedes
>
11 <link href=
"sx4ca.html" rel=precedes
>
12 <link href=
"sx4a.html" rev=subdocument
>
15 <H3>18.1.2:
<TT>short int
</TT></H3>
17 <p>Another type we haven't met is
<TT>short int
</TT>.
19 has the same guarantees as a plain
<TT>int
</TT>:
20 it will hold integers in at least the range +-
32,
767.
21 The difference between
<TT>short int
</TT> and plain
<TT>int
</TT>
22 is that
<TT>short int
</TT> <em>might
</em> be smaller.
23 Remember, the definitions of both these types
25 is that they have
<em>at least
</em> the specified range.
26 On some machines, plain
<TT>int
</TT> will hold numbers greater than
32,
767.
29 it's common for plain
<TT>int
</TT> to be
32 bits,
30 and to hold +-
2,
147,
483,
647.
31 Yes, this is all the way up to the minimum range
32 for a
<TT>long int
</TT>.)
33 You might use a
<TT>short int
</TT> when you had a lot of them
34 and were worried about saving memory.
35 If you had a large array of integers all less than
32,
768,
36 or a large number of structures with one or more members holding
37 integers all less than
32,
768,
38 you might declare the array or the structure members as
<TT>short int
</TT>,
39 to avoid devoting
4 bytes to each of them on
32-bit machines.
43 <a href=
"sx4aa.html" rev=precedes
>prev
</a>
44 <a href=
"sx4ca.html" rel=precedes
>next
</a>
45 <a href=
"sx4a.html" rev=subdocument
>up
</a>
46 <a href=
"top.html">top
</a>
49 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
50 //
<a href=
"copyright.html">Copyright
</a> 1996-
1999
51 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>