Time complexity of this while loop So, i would like to know the time complexity of the following codes:

x = (float) rand() / rand();   // T(4)

while (x &gt;= 0.01)   // T(?)
{
    x *= 0.8;  // T(?) x T(2)
}


Assuming that all the basic operations are perfomed once, is the best case T(1) - constant time? Since, that might only happen when the random x generated is &lt;= 0.01.

What about the average case? Is it T(?) x T(1) / 2?

Thanks a lot!
Worst case, if the second call to rand() returns 0 and the first call doesn't, you get a floating point division by zero, and if you are using standard IEEE 754 arithmetic, the result is +infinity. In that case, the loop will run forever. 

If you changed your code to exclude that case, and exclude the case that rand () might return a 128 bit integer, then for any implementation the size of x is limited, so the number of multiplications by 0.8 is limited, so the runtime is O (1).