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
Post a Comment