Go Down

Topic: U & L formatters (Read 395 times) previous topic - next topic

bhuvaneshnick



Quote
By default, an integer constant is treated as an int with the attendant limitations in values. To specify an integer constant with another data type, follow it with:
a 'u' or 'U' to force the constant into an unsigned data format. Example: 33u

int a=33u
is that mean mean unsigned integer

PaulS

Quote
int a=33u
is that mean mean unsigned integer

Yes. The value 33u will be treated as an unsigned int. Silly to store that in a signed int, then.


bhuvaneshnick

is byte data type only for binary representation

which of the following is correct
byte a=B1001;
or
byte a=65;

PaulS

Quote
is byte data type only for binary representation

The Arduino (and all other computers) only knows how to store data in binary. The compiler is responsible for converting decimal, octal, binary, hexadecimal, etc. representations to binary. So, the answer to your question is no.

Quote
which of the following is correct

Both are correct.

AWOL

Quote
which of the following is correct
byte a=B1001;
or
byte a=65;


In Arduino-world, both are correct (though obviously not equivalent), but only the latter is portable.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

MarkT

Code: [Select]
byte a=B1001;
is best avoided, since you can use
Code: [Select]
byte a=0b1001;
which isn't Arduino-specific and allows modifiers like
Code: [Select]
byte a=0b1001U;

Don't write a long modifier as 'l', always use 'L' since it otherwise is
readily confused with a one.  Consider 1111l and 1111L
[ I won't respond to messages, use the forum please ]

Go Up