Meaning of U suffix

C++C

C++ Problem Overview


What does the postfix (or suffix) U mean for the following values?

0U
100U

C++ Solutions


Solution 1 - C++

It stands for unsigned.

When you declare a constant, you can also specify its type. Another common example is L, which stands for long. (and you have to put it twice to specify a 64-bit constant).

Example: 1ULL.

It helps in avoiding explicit casts.

Solution 2 - C++

Integer constants in C and C++ can optionally have several suffixes:

123u      the value 123 is an unsigned int
123l       (that's a lowercase L) 123 is a signed long
123L      ditto
123uL    unsigned long
123LL    a signed long long, a 64 bit or 128 bit value (depending on the environment)
123uLL  unsigned long long

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlovespringView Question on Stackoverflow
Solution 1 - C++ruslikView Answer on Stackoverflow
Solution 2 - C++wallykView Answer on Stackoverflow