Question

I am looking through some c++ code and I came across this:

if( (size & 0x03L) != 0 )
    throw MalformedBundleException( "bundle size must be multiple of four" );

what does L stand for after the hexadecimal value ?

how does it alter the value 0x03 ?

Was it helpful?

Solution

It means Long, as in, the type of the literal 0x03L is long instead of the default int. On some platforms that will mean 64 bits instead of 32 bits, but that's entirely platform-dependent (the only guarantee is that long is not shorter than int).

OTHER TIPS

This suffix sets the type of the numeric literal. L stands for long; LL stands for long long type. The number does not need to be hex - it works on decimals and octals as well.

3LL  // A decimal constant 3 of type long long
03L  // An octal constant 3 of type long
0x3L // A hex constant 3 of type long

It means so-called long-suffix of integer literals and denotes that the type of the literal is int long The integer literal in your example is hexadecomal integer literal of type int long. You can meet also two LL (or ll) that denote type int long long

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top