* remove "\r" nonsense
[mascara-docs.git] / C / the.ansi.c.programming.language / notes.accompany.ansi.c / sx5.html
blob82fcad8f22032cd01253f0f022afdd8387f7e9ed
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>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>
13 </head>
14 <body>
15 <H1>Chapter 2: Types, Operators, and Expressions</H1>
17 <p>page 35
18 </p><p>Deep sentence:
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
25 finite.
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,
30 you
31 may
32 have to remember what values it can take on and what
33 operations you can perform on it.
34 For example,
35 there are several operators which
36 play with
38 the binary (bit-level) representation of integers,
39 but these operators
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.
45 </OL>In other words,
46 picking a type for a variable is not some abstract academic exercise;
47 it's closely
48 connected
49 to the way(s) you'll be using that variable.
50 <p>You don't need to worry about
51 the
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
54 in its history.
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>
70 <hr>
71 <p>
72 Read sequentially:
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>
77 </p>
78 <p>
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>
82 </p>
83 </body>
84 </html>