#include <stdio.h>int main(){ unsigned len,middle,left,right; scanf("%u",&len); left=0,right=31; if( len > (1u<<right) ) { printf("len is too big\n"); return 1; } if(len <= 1u )//особый случай right=0; else while(left+1 < right) { middle=(left+right)/2u; if(len <= (1u<<middle)) right=middle; else left=middle; } printf("power= %u new len=%u\n",right,(1u<<right)); return 0;}
int order = 1;if( len ) len--;while( len ) { len <<= 1; order >>= 1;}
-5 & 10 == 10 != 8
unsigned fun(unsigned x){ x = x - 1; x = x | (x >> 1); x = x | (x >> 2); x = x | (x >> 4); x = x | (x >> 8); x = x | (x >> 16); return x = x + 1;}