number-as-string
Version:
Precise number scaling and formatting without JavaScript floating-point precision issues
16 lines • 682 B
TypeScript
/**
* Trims the decimals of a number or string to the specified number of decimal places.
*
* @param value - The number or string to trim.
* @param decimals - The number of decimal places to trim to.
* @returns The trimmed number or string.
* @throws An error if the decimals parameter is not a non-negative integer.
* @throws An error if the input is Infinity or NaN.
*
* @example
* // 0.2161.toFixed(18) = '0.216099999999999987'
* // 0.2161.toPrecision(18) 0.216099999999999987
* trimWithPrecision(0.2161, 18) // '0.2161'
*/
export declare function trimWithPrecision(value: number | string, decimals: number): string;
//# sourceMappingURL=trim-with-precision.d.ts.map