1.0.0 • Published 9 years ago
count-digits v1.0.0
count-digits
Counts the digits of an integer in any base.
Usage
countDigits(value[, base=10])Example
var countDigits = require('count-digits');
countDigits(100); // => 3
countDigits(1000); // => 4
countDigits(1e4); // => 5
countDigits(0xff, 16); // => 2
countDigits(0xff, 2); // => 8Installing
$ npm install --save count-digitsNotes
Zero
Zero is a special case when counting digits. Be aware that countDigits(0) will return 0 where you might be expecting 1.
Floats
Since only whole values are counted, countDigits(Math.PI) will return 1.
License
MIT.