 # What is LL in hexadecimal?

I am looking at an Arduino code snippet

// Radio pipe addresses for the 2 nodes to communicate. const uint64_t pipes = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

I didn't know that there was an 'L' in hexadecimal! What is the function of the "LL"?

I didn't know that there was an 'L' in hexadecimal!

There isn't. The L, UL, and LL suffixes mean long, unsigned long, and long long.

Thanks PaulS

Firstly, If the constant is already declared:

const uint64_t pipes = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

doesn't the uint64_t mean that it is long long int already?

Secondly, 0xF0F0F0F0E1 is 40 bits (if I am not totally confused). I guess you have to go for 64-bit because you can't get the number in 32-bit.

doesn’t the uint64_t mean that it is long long int already?

The variable type is long long. That doesn’t mean that the literal assigned to it will be interpreted as a long long.

Secondly, 0xF0F0F0F0E1 is 40 bits (if I am not totally confused). I guess you have to go for 64-bit because you can’t get the number in 32-bit.

Correct. The next step up from 32 bits is 64 bits.

PaulS: The variable type is long long. That doesn't mean that the literal assigned to it will be interpreted as a long long.

You lost me!

C++ is supposed to be strongly typed, and I suppose Arduino is also. If the variable type is 64-bit integer how can it be interpreted as anything else?

I believe that for Arduino C/C++, the default assignment for a constant on the right hand side of "=" is a [u]16 bit integer[/u].

There is no problem putting a 16 bit integer into a longer variable. The reverse is obviously not true.

jremington: I believe that for Arduino C/C++, the default assignment for a constant on the right hand side of "=" is a [u]16 bit integer[/u].

Fine. We have declared a 64-bit integer constant, and in this case we have stored a 40-bit integer at that address. I would have assumed that the F0F0F0F0E1 would simply be stored with preceding zeros, I think it should look like 000000F0F0F0F0E1.

Surely, if that is read as a 64-bit integer or a 40-bit integer it would still equate to decimal 1034834473185.

Actually, constants are always interpreted as "big enough" to hold the specified value, so 0x1234000099 will be be a 64bit constant with or without the LL suffix. Where it gets complicated is when you do math. "3000 * 4000" will be different than "3000L * 4000" (and the first one will probably be WRONG, since 120000000 doesn't fit in an "int.")

if that is read as a 64-bit integer or a 40-bit integer it would still equate to decimal 1034834473185.

Yes. You don't need to put all the leading zeros on a 64 bit constant any more than you need to put them on a 16bit constant. 0x13 == 0x0013 too.

jremington: I believe that for Arduino C/C++, the default assignment for a constant on the right hand side of "=" is a [u]16 bit integer[/u].

There is no problem putting a 16 bit integer into a longer variable. The reverse is obviously not true.

Specifically, it is interpreted as an int. It just so happens that AVR-GCC makes int 16 bits wide for the 8-bit architectures, but other processors (such as the 32-bit ARM used by the Due) can use a different sized int type, such as 32 bits.

Thanks for that, folks.