E.8. Suffixes for Integer and Floating-Point Constants

C++ provides integer and floating-point suffixes for specifying the types of integer and floating-point constants. The integer suffixes are: u or U for an unsigned integer, l or L for a long integer, and ul or UL for an unsigned long integer. The following constants are of type unsigned, long and unsigned long, respectively:

 174u
 8358L
 28373ul

If an integer constant is not suffixed, its type is int; if the constant cannot be stored in an int, it is stored in a long.

The floating-point suffixes are f or F for a float and l or L for a long double. The following constants are of type long double and float, respectively:

 3.14159L
 1.28f

A floating-point constant that is not suffixed is of type double. A constant with an improper suffix results in either a compiler warning or an error.





C++ How to Program
C++ How to Program (5th Edition)
ISBN: 0131857576
EAN: 2147483647
Year: 2004
Pages: 627
Simiral book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net