Go Down

Topic: what does capital U stand for in C (Read 168 times) previous topic - next topic

ultrasonicbananna

Hi,

In the following c code, what does U stand for? I get that the code moves left shifts 1 by x bits but why is the one necessary?

Code: [Select]
/* Bitwise operation helpers */
#ifndef BIT
#define BIT(x) (1U << (x))
#endif


Thanks

pert

Integer constants are treated as int by default. By adding U it will be treated as unsigned int instead. See the "U & L formatters" section of https://www.arduino.cc/en/Reference/IntegerConstants for more information.

ultrasonicbananna

Ok thanks- why does it need a bitwise operation require an unsigned int? Sorry if that is an obvious question but I don't get it. Thanks

Go Up