Specifying integer literals

To assign a value to an integer variable you provide a number that has no fractional part. The compiler will identify the type with the nearest precision that the number represents and attempt to assign the integer, performing a conversion if necessary.

To explicitly specify that a literal is a long value, you use the l or L suffix. Similarly, for an unsigned long, you use the suffix ul or UL. For long long values, you use ll or LL suffix, and use ull or ULL for unsigned long long. The u (or U) suffix is for unsigned (that is, unsigned int) and you do not need a suffix for int. The following illustrates this, using uppercase suffixes:

    int i = 3;     signed s = 3;     unsigned int ui = 3U;     long l = 3L;  unsigned long ...

Get Beginning C++ Programming 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.