(val: number)
| 579 | * @return |
| 580 | */ |
| 581 | export function quantityExponent(val: number): number { |
| 582 | if (val === 0) { |
| 583 | // PENDING: like IEEE754 use exponent `0` in this case. |
| 584 | // but methematically, exponent of zero is `-Infinity`. |
| 585 | return 0; |
| 586 | } |
| 587 | |
| 588 | let exp = mathFloor(mathLog(val) / mathLN10); |
| 589 | /** |
| 590 | * exp is expected to be the rounded-down result of the base-10 log of val. |
| 591 | * But due to the precision loss with Math.log(val), we need to restore it |
| 592 | * using 10^exp to make sure we can get val back from exp. #11249 |
| 593 | */ |
| 594 | if (val / mathPow(10, exp) >= 10) { |
| 595 | exp++; |
| 596 | } |
| 597 | return exp; |
| 598 | } |
| 599 | |
| 600 | export const NICE_MODE_ROUND = 1 as const; |
| 601 | export const NICE_MODE_MIN = 2 as const; |
no outgoing calls
no test coverage detected
searching dependent graphs…