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. -->
7 <link rev=
"owner" href=
"mailto:scs@eskimo.com">
8 <link rev=
"made" href=
"mailto:scs@eskimo.com">
9 <title>Chapter
2: Types, Operators, and Expressions
</title>
10 <link href=
"sx4n.html" rev=precedes
>
11 <link href=
"sx5a.html" rel=precedes
>
12 <link href=
"top.html" rev=subdocument
>
15 <H1>Chapter
2: Types, Operators, and Expressions
</H1>
19 <blockquote>The type of an object determines the set of values it can have
20 and what operations can be performed on it.
21 </blockquote>This is a fairly formal, mathematical definition of what a type is,
22 but it is traditional (and meaningful).
23 There are several implications to remember:
24 </p><OL><li>The ``set of values'' is
26 C's
<TT>int
</TT> type can not represent
<em>all
</em> of the integers;
27 its
<TT>float
</TT> type can not represent
<em>all
</em>
28 floating-point numbers.
29 <li>When you're using an object (that is, a variable) of some type,
32 have to remember what values it can take on and what
33 operations you can perform on it.
35 there are several operators which
38 the binary (bit-level) representation of integers,
40 are not meaningful for
41 and may not be applied to
42 floating-point operands.
43 <li>When declaring a new variable and picking a type for it,
44 you have to keep in mind the values and operations you'll be needing.
46 picking a type for a variable is not some abstract academic exercise;
49 to the way(s) you'll be using that variable.
50 <p>You don't need to worry about
52 list of ``small changes and additions'' made by the ANSI standard,
53 unless you started learning C long ago or have a keen interest
55 We'll be using these new features indiscriminately,
56 usually without comment.
58 </p><p><a href=
"sx5a.html" rel=subdocument
>section
2.1: Variable Names
</a></p>
59 <p><a href=
"sx5b.html" rel=subdocument
>section
2.2: Data Types and Sizes
</a></p>
60 <p><a href=
"sx5c.html" rel=subdocument
>section
2.3: Constants
</a></p>
61 <p><a href=
"sx5d.html" rel=subdocument
>section
2.4: Declarations
</a></p>
62 <p><a href=
"sx5e.html" rel=subdocument
>section
2.5: Arithmetic Operators
</a></p>
63 <p><a href=
"sx5f.html" rel=subdocument
>section
2.6: Relational and Logical Operators
</a></p>
64 <p><a href=
"sx5g.html" rel=subdocument
>section
2.7: Type Conversions
</a></p>
65 <p><a href=
"sx5h.html" rel=subdocument
>section
2.8: Increment and Decrement Operators
</a></p>
66 <p><a href=
"sx5i.html" rel=subdocument
>section
2.9: Bitwise Operators
</a></p>
67 <p><a href=
"sx5j.html" rel=subdocument
>section
2.10: Assignment Operators and Expressions
</a></p>
68 <p><a href=
"sx5k.html" rel=subdocument
>section
2.11: Conditional Expressions
</a></p>
69 <p><a href=
"sx5l.html" rel=subdocument
>section
2.12: Precedence and Order of Evaluation
</a></p>
73 <a href=
"sx4n.html" rev=precedes
>prev
</a>
74 <a href=
"sx5a.html" rel=precedes
>next
</a>
75 <a href=
"top.html" rev=subdocument
>up
</a>
76 <a href=
"top.html">top
</a>
79 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
80 //
<a href=
"copyright.html">Copyright
</a> 1995,
1996
81 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>