Floating-Point Numbers
Now that you have seen the complete line of C++ integer types, let's look at the floating-point types, which compose the second major group of fundamental C++ types. These numbers let you represent numbers with fractional parts, such as the gas mileage of an M1 tank (0.56 MPG). They also provide a much greater range in values. If a number is too large to be represented as type long, for example, the number of stars in our galaxy (an estimated 400,000,000,000), you can use one of the floating-point types.
With floating-point types, you can represent numbers like 2.5 and 3.14159 and 122442.32—that is, numbers with a fractional part. A computer stores such values in two parts. One part represents a value, and the other part ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access