Conversation
Notices
-
!CoderPonies Anyone know a simple algorithm for finding the number of digits in a number? Like 138273 = 6. xD
Wednesday, 19-Sep-12 22:17:58 UTC from web-
@minti Divide by ten until the number is less than ten, while keeping a count of number of divisions?
-
@cabinboybitshift Was trying to avoid using division. Hmm, time for a jsperf I think xD
-
@minti Of course, that would only work for integers, but still.
-
@minti Of course, considering how optimised various conversions are, you might find len(n.toString()) ends up actually faster than anything you could hack together. :P
-
@minti I'd appreciate if everyone opened this in their browsers and ran it, please.
-
@minti What does it prove
-
@renovatedkitchen Which method of getting the number of digits in a number is fastest. So far, regular old "count them by dividing by 10" seems fastest. O_o;
-
@minti Wait what? I'm lost here
-
@minti Im with bagles
-
@minti I'd probably get better results by closing this chrome profile and running it on a vanilla one, but oh well. http://ur1.ca/ac4zv
-
@baglesman Click link, "run test", let it finish, close page. It'll just collect some information for me. :p
-
@nerthos Thanks!
-
@minti What's this for?
-
@nerthos Me being OCD about how to do stuff the fastest way possible. xD
-
@minti Oh, sounds typical you xD
-
@nlghtmaremoon I have no clue. I just got done watching a horror movie and I did this test thingy.
-
@nerthos Yeah, basically. xD
-