Selecting a Number Type

Choosing the right type of number to use in a C application is critical, as it affects both the range of computational possibilities and the overall performance. Each of the available number types has its own strengths and weaknesses. More important, each has its own dangers, which can trip up even a thoughtful programmer.

C supports two broad types of numbers: integers (1, 2345, -8) and floating points (3.14, -0.8, 23.2). The latter always contain decimal points, whereas the former never do. Each of these is then further broken down into subtypes based on their size. Floats can also be represented as doubles, which are twice as accurate (more on this later). Also, integers (but not floats and doubles) can be defined as ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.