(val, ceil, e, round, roundingFunc, autoExponent)
| 312 | * @returns {Object} Object with rounded value and possibly incremented exponent |
| 313 | */ |
| 314 | export function applyRounding(val, ceil, e, round, roundingFunc, autoExponent) { |
| 315 | let p; |
| 316 | if (e > 0 && round > 0) { |
| 317 | p = Math.pow(10, round); |
| 318 | } else { |
| 319 | p = 1; |
| 320 | } |
| 321 | let r; |
| 322 | if (p === 1) { |
| 323 | r = roundingFunc(val); |
| 324 | } else { |
| 325 | r = roundingFunc(val * p) / p; |
| 326 | } |
| 327 | |
| 328 | if (r === ceil && e < 8 && autoExponent) { |
| 329 | r = 1; |
| 330 | e++; |
| 331 | } |
| 332 | |
| 333 | return { value: r, e }; |
| 334 | } |
| 335 | |
| 336 | /** |
| 337 | * Resolves the unit symbol for the given standard, bits mode, and exponent |
no outgoing calls
no test coverage detected