/** * 1 + Floor(LogBase10(number)) * */ function digits(n) { return 1+Math.floor(Math.log(n)/Math.log(10)); } Yes, javascript doesn’t have a Math.log10() function. I tried doing it by dividing by Math.ln10 constant but the function won’t return the correct number of digits when you pass numbers like 100,1000,10000,etc. So I just divided by Math.log(10) and it seems to […]
2 thoughts on “Geek T-Shirt Collection #28 – Google IO 2011”