Go Down

### Topic: U & L formatters (Read 1 time)previous topic - next topic

#### bhuvaneshnick

##### Dec 28, 2013, 12:13 pm

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

#1
##### Dec 28, 2013, 12:15 pm
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

#2
##### Dec 28, 2013, 12:43 pm
is byte data type only for binary representation

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

#### PaulS

#3
##### Dec 28, 2013, 12:46 pm
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

#4
##### Dec 28, 2013, 12:49 pm
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.
I speak for myself, not Arduino.

#### MarkT

#5
##### Dec 28, 2013, 02:56 pm
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 will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up