MCPcopy Index your code
hub / github.com/apache/echarts / quantityExponent

Function quantityExponent

src/util/number.ts:581–598  ·  view source on GitHub ↗
(val: number)

Source from the content-addressed store, hash-verified

579 * @return
580 */
581export 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
600export const NICE_MODE_ROUND = 1 as const;
601export const NICE_MODE_MIN = 2 as const;

Callers 4

number.test.tsFile · 0.90
increaseIntervalFunction · 0.90
quantityFunction · 0.85
niceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…