Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 5x 5x 5x 5x 29x 29x 29x 29x 29x 13x 16x 5x 11x 11x 4x 7x 7x | import Big from 'big.js';
import * as R from 'ramda';
import { formatDecimalNoRound } from './formatDecimalNoRound';
import { RestParams } from './interface';
/**
* 小数字转大数字
* @param translateUnit
*/
export const smallToBig = (translateUnit: number) => {
return (num: number | string, params?: RestParams) => {
Iif (R.isEmpty(num) || R.isNil(num)) return num;
Iif (isNaN(Number(num))) {
return NaN;
}
const newNumber = Number(new Big(Number(num)).mul(translateUnit));
if (R.isNil(params?.decimalNumber) && R.isNil(params?.fn)) {
return newNumber;
}
if (!R.isNil(params?.decimalNumber) && R.isNil(params?.fn)) {
return Number(newNumber.toFixed(params?.decimalNumber));
}
Eif (!R.isNil(params?.decimalNumber) && !R.isNil(params?.fn)) {
if (params?.fn === 'toFixed') {
return Number(newNumber.toFixed(params?.decimalNumber));
} else Eif (params?.fn === 'floor') {
return formatDecimalNoRound(newNumber, params?.decimalNumber);
}
}
}
} |