Can someone please tell me what does this line of code do?
wait = (20ul*50ul)-1ul ;
I understand the mathematics that is carried out which is the product of 20 and 50 then subtract 1 from it but I dont understand the ul part. Is it just a unit or does it have any significance. Thank you
ul is a notational shorthand for Unsigned Long.
The ul suffix forces each constant expression to be type unsigned long.
Normally, the type of an integer constant expression is the first type in which its value can be represented. Without the suffix, each of the literal expressions 20, 50, and 1 would be type int instead of unsigned long.
For this particular calculation it doesn't really matter, but there are times when you do want to force unsigned operations on constant expressions (overflow on unsigned operations is well-defined).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With