c++ - Number of Elements in a long long. -
is there way number of element in long long in c++? example want count number of element in 0x993232bf, answer should 8. in advance.
int count_nibbles(long long n) { int r=0; while(n > 0) { n >>= 4; r++; } return r; }
or if prefer suggested in comments:
int count_nibbles(long long n) { for(; n > 0; n >>= 4) r++; return r; }
Comments
Post a Comment