Check digits in number

Benchmark created on


Description

Check digits in a number is greater than certain threshold

Setup

function countDigitsByLog(num, threshold) {
    return Math.log10(num) > threshold
}

function countDigitsByStr(num, threshold) {
    return parseInt(num, 10).toString().length > threshold
}

Test runner

Ready to run.

Testing in
TestOps/sec
countDigitsByLog(1234, 3)
countDigitsByLog(1234, 3)
ready
countDigitsByStr(1234, 3)
countDigitsByStr(1234, 3)
ready
countDigitsByLog(123, 3)
countDigitsByLog(123, 3)
ready
countDigitsByStr(123, 3)
countDigitsByStr(123, 3)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.