Does anyone know a fast algorithm in C to compute (int)log2(x), x real in [0,1] The standard C function frexp does this , but it can be as slow as using the log function directly. Any help will be appreciated. Thanks