Computing integer square roots in Java - follow-up
When using function parameters, use the primitive types when available:


Function&lt;Long, Long&gt; function



is a red-flag, and should be LongUnaryOperator.

Your code will spin in to an infinite loop for 25% of all long values .... anything larger than Long.MAX_VALUE/4 will cause this loop to become infinite:


    // Do the exponential search.
    while (4 * sqrt * sqrt &lt;= number) {
        sqrt *= 2;
    }



About that loop.... why do you have a magic number 4....? What does it do?

This code needs more testing... and magic numbers need to be removed.