Find the power of b less than and greater than b
A = Math . floor ( Math . pow ( b , log_b ) ) ; B = Math . floor ( Math . pow ( b , log_b + 1 ) ) ; if ( ( arr [ i ] - A ) < ( B - arr [ i ] ) ) log_b = A ; else log_b = B ;