tachybase_todo/packages/core/utils/src/number.ts
SemmyWong 92cd76ce48
fix: fix accuracy of percent (#685)
* fix: fix accuracy of percent

* fix: fix accuracy of percent

* fix: test unit modify

* fix: export number

Co-authored-by: chenos <chenlinxh@gmail.com>
2022-07-28 09:26:50 +08:00

12 lines
454 B
TypeScript

import { toFixed } from 'rc-input-number/lib/utils/MiniDecimal';
import { getNumberPrecision } from 'rc-input-number/lib/utils/numberUtil';
export function toFixedByStep(value: any, step: string | number) {
if (typeof value === 'undefined' || value === null || value === '') {
return '';
}
const precision = getNumberPrecision(step);
// return parseFloat(String(value)).toFixed(precision);
return toFixed(String(value), '.', precision);
}