Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean when numbers end with U

Tags:

c

literals

As in this code:

int nx = (int)((rev3[gx]) / 193U);

Whats with the U in the end of 193 ?

like image 957
jtm Avatar asked Mar 07 '10 22:03

jtm


3 Answers

The u is unsigned, that is: 1 is the int value 1, and 1u is the unsigned int value 1.

like image 65
Dirk Avatar answered Oct 18 '22 19:10

Dirk


It means that the number is an unsigned int, which is a data type much like an int except that it has no negative values, which is a trade-off it makes so that it can store larger values (twice as large as a regular int).

like image 3
Peter Alexander Avatar answered Oct 18 '22 19:10

Peter Alexander


It means it's an unsigned int constant. It's a way of telling the compiler to use a specific type for a constant where it wouldn't otherwise know the type. A naked 193 would be treated as an int normally.

It's similar to the L suffix for long, the ULL for unsigned long long and so forth.

like image 2
paxdiablo Avatar answered Oct 18 '22 19:10

paxdiablo