Chapter 2: Types, Operators, and Expressions

page 35

Deep sentence:

The type of an object determines the set of values it can have and what operations can be performed on it.
This is a fairly formal, mathematical definition of what a type is, but it is traditional (and meaningful). There are several implications to remember:

1. The ``set of values'' is finite. C's int type can not represent all of the integers; its float type can not represent all floating-point numbers.
2. When you're using an object (that is, a variable) of some type, you may have to remember what values it can take on and what operations you can perform on it. For example, there are several operators which play with the binary (bit-level) representation of integers, but these operators are not meaningful for and may not be applied to floating-point operands.
3. When declaring a new variable and picking a type for it, you have to keep in mind the values and operations you'll be needing.
In other words, picking a type for a variable is not some abstract academic exercise; it's closely connected to the way(s) you'll be using that variable.

You don't need to worry about the list of ``small changes and additions'' made by the ANSI standard, unless you started learning C long ago or have a keen interest in its history. We'll be using these new features indiscriminately, usually without comment.

section 2.1: Variable Names

section 2.2: Data Types and Sizes

section 2.3: Constants

section 2.4: Declarations

section 2.5: Arithmetic Operators

section 2.6: Relational and Logical Operators

section 2.7: Type Conversions

section 2.8: Increment and Decrement Operators

section 2.9: Bitwise Operators

section 2.10: Assignment Operators and Expressions

section 2.11: Conditional Expressions

section 2.12: Precedence and Order of Evaluation

Read sequentially: prev next up top