* remove "\r" nonsense
[mascara-docs.git] / C / the.ansi.c.programming.language / notes.accompany.ansi.c / sx5b.html
blobf093616453afdcb5f65a22a2e5df465433540586
1 <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995, 1996 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
5 <html>
6 <head>
7 <link rev="owner" href="mailto:scs@eskimo.com">
8 <link rev="made" href="mailto:scs@eskimo.com">
9 <title>section 2.2: Data Types and Sizes</title>
10 <link href="sx5a.html" rev=precedes>
11 <link href="sx5c.html" rel=precedes>
12 <link href="sx5.html" rev=subdocument>
13 </head>
14 <body>
15 <H2>section 2.2: Data Types and Sizes</H2>
17 page 36
18 <p>If you can look at this list of
19 ``a few basic types in C''
20 and say to yourself,
21 ``Oh, how simple, there are only a few types,
22 I won't have to worry much about choosing among them,''
23 you'll have an easy time with declarations.
24 (Some masochists wish that the type system were more complicated
25 so that you could specify more things about each variable,
26 but those of us who would rather not have to specify these
27 extra things each time are glad that we don't have to.)
28 </p><p>Note that the basic types are defined as having
29 <em>at least</em> a certain size.
30 There is no specification that
31 a <TT>short int</TT> will be exactly 16 bits,
32 or that a <TT>long int</TT> will be exactly 32 bits.
33 Some programmers become obsessed with knowing exactly what
34 sizes things will be in various situations,
35 and write programs which depend on things having certain sizes.
36 Exact sizes are occasionally important,
37 but most of the time we can sidestep size issues
38 and let the compiler do most of the worrying.
39 </p><p>Most of the simple variables in most programs are of types
40 <TT>int</TT>, <TT>long int</TT>, or <TT>double</TT>.
41 Typically, we'll use <TT>int</TT> and <TT>double</TT> for most
42 purposes, and <TT>long int</TT> any time we need to hold values
43 greater than 32,767.
44 We'll rarely use individual variables of type <TT>char</TT>;
45 although we'll use plenty of arrays of <TT>char</TT>.
46 Types <TT>short int</TT> and <TT>float</TT> are important primarily when
47 efficiency (speed or memory usage) is a concern,
48 and for us it usually won't be.
49 </p><p>Note that even when we're manipulating individual characters,
50 we'll usually use an <TT>int</TT> variable,
51 for the reason discussed in section 1.5.1
52 on page 16.
53 <br></p><hr>
54 <p>
55 Read sequentially:
56 <a href="sx5a.html" rev=precedes>prev</a>
57 <a href="sx5c.html" rel=precedes>next</a>
58 <a href="sx5.html" rev=subdocument>up</a>
59 <a href="top.html">top</a>
60 </p>
61 <p>
62 This page by <a href="http://www.eskimo.com/~scs/">Steve Summit</a>
63 // <a href="copyright.html">Copyright</a> 1995, 1996
64 // <a href="mailto:scs@eskimo.com">mail feedback</a>
65 </p>
66 </body>
67 </html>