binary - How to use constant powers of 2 readable in c++? -


i need several integer constants 2^n , 2^n - 1 in gnu c++ code.

what practise keep code readable? code uses decimal values @ moment 4294967296 , 65536 hard debug in future.

2^12 not implemented in standard c++ , pow(2.0,12.0) uses double.

if (buffer_length == 4294967295){ } // code example, want make more readable 

you can use shift left operator:

if (buffer_length == 1 << 12){ }  

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -