You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
351 B
11 lines
351 B
exports = function(num) {
|
|
num = num.toExponential().match(regExponential);
|
|
var coefficient = num[1];
|
|
var exponent = parseInt(num[2], 10);
|
|
var places = (coefficient.split('.')[1] || '').length;
|
|
var ret = places - exponent;
|
|
return ret < 0 ? 0 : ret;
|
|
};
|
|
var regExponential = /^(-?\d?\.?\d+)e([+-]\d)+/;
|
|
|
|
module.exports = exports;
|
|
|