()
| 26 | |
| 27 | // 计算最长小数位数 |
| 28 | const getMaxDecimalDigits = function () { |
| 29 | let maxDecimalDigits = 0 |
| 30 | const numberList = arguments[0] |
| 31 | for (let i = 0; i < numberList.length; i++) { |
| 32 | // 如果是科学计数法 |
| 33 | if (String(numberList[i]).indexOf("e") !== -1) { |
| 34 | numberList[i] = scientificNotationToString(numberList[i]) |
| 35 | } |
| 36 | try { |
| 37 | maxDecimalDigits = Math.max(maxDecimalDigits, String(numberList[i]).split(".")[1].length) |
| 38 | } catch (e) { |
| 39 | maxDecimalDigits = Math.max(maxDecimalDigits, 0) |
| 40 | } |
| 41 | } |
| 42 | return maxDecimalDigits |
| 43 | } |
| 44 | // 科学计数法转字符串 |
| 45 | const scientificNotationToString = function (number) { |
| 46 | let numberString = String(number) |
no test coverage detected