Floating Point Types

Integers and characters are integral types: the values of these types are separated from each other by values that are multiples of one. They cannot contain fractional parts. Or, rather, whatever bit pattern they contain, that bit pattern cannot be interpreted by the C++ compiler as a fraction. Other types are used if the fractional part is needed.

C++ does not have fixed point numbers that would give the programmer control over the number of digits after the decimal point. Instead, the programmer can use floating point values that consist of a mantissa (with whole and fractional parts) and an exponent. The exponent is expressed in literal numbers as a power of ten, but in the computer memory it is, of course, expressed ...

Get Core C++ A Software Engineering Approach 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.