(val, dec = 0)
| 360 | // https://stackoverflow.com/a/48764436 |
| 361 | // rounds half away from zero |
| 362 | export function roundDec(val, dec = 0) { |
| 363 | if (isInt(val)) |
| 364 | return val; |
| 365 | // else if (dec == 0) |
| 366 | // return round(val); |
| 367 | |
| 368 | let p = 10 ** dec; |
| 369 | let n = (val * p) * (1 + Number.EPSILON); |
| 370 | return round(n) / p; |
| 371 | } |
| 372 | |
| 373 | // https://stackoverflow.com/questions/14879691/get-number-of-digits-with-javascript/28203456#28203456 |
| 374 | export function numDigits(x) { |
no outgoing calls
no test coverage detected
searching dependent graphs…