Finding the Power

Hi, I am trying to take a number and round it up to the nearest power of two, and then get what power the number was raised too.
For example 1133 will become 2048 since I want the next power of 2(I have done this), Now I want to take the 2048 and figure out the power value X. I know its 2^11.

    int num =1133;
    int X = 1; 
    while (X < num) X <<= 1;
// X will become 2048 
The logarithm is the inverse of the power function.

y = logbx

x = by

Good luck!
Topic archived. No new replies allowed.