tags:

views:

165

answers:

5

As in this code:

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

Whats with the U in the end of 193 ?

+5  A: 

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

Dirk
And the effect of it in this case is that if `rev3[gx]` is an int, and therefore could be negative, that it will be converted to `unsigned` before being divided by 193. On my machine `(int)(-1 / 193)` is 0, whereas `(int)(-1 / 193U)` is 22253716. But if `rev3[gx]` is a signed integer type *bigger* than int, then the U makes no difference to the result: `(-1LL/193U) == (-1LL/193)`, both are type long long. Got to love them integer promotion rules.
Steve Jessop
+2  A: 

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.

paxdiablo
+2  A: 

U means unsigned.

Have a look here for more: http://cplus.about.com/od/learnc/ss/variables_6.htm

Ninefingers
+3  A: 

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).

Peter Alexander
A: 

It means to treat the value as an unsigned value

Sean