Go Down

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



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



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.


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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131