1.0.0 • Published 8 years ago

count-digits v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

count-digits

master branch build status

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);  // => 8

Installing

$ npm install --save count-digits

Notes

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.