U can take logarithm base 2, and check the result is in interger form or floating point form, u can check whether it is power of 2 or not.
assume : x is input number and want to check whethe x is power of two or not. code: result = x & (x-1); if( result == 1) x is not power of two else x is power of two.
U can take logarithm base 2, and check the result is in interger form or floating point form, u can check whether it is power of 2 or not.
assume : x is input number and want to check whethe x is power of two or not. code: result = x & (x-1); if( result == 1) x is not power of two else x is power of two.
Whats is structure padding?Say a given structure Struct{ int a; char c; float d; } the size of structure is 7 here. But structure padding is done what will be the size of the struct?Will it change and how?How to avoid this?is it necessary?