Create a long from hex

Folks, I start loosing it… :o

long l = 64 << 24 | 64 << 16 | 64 << 8 | 64 ;

should be 1077952576 but it is 16448. it only takes the first two bytes from the right

64 << 8 | 64 = 16448

why?

the default number is an int for the compiler so try

long l = 64L << 24 | 64L << 16 | 64L << 8 | 64L ;

it works - thanks Rob

The L suffix indicates to the compiler to treat the number as a LONG

There are also the UL (unsigned long) LL (long long) and ULL (unsigned long long)

The latter two are 64 bit and really slow