@xylabs/decimal-precision
v5.1.2
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Readme
@xylabs/decimal-precision
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Install
Using npm:
npm install {{name}}Using yarn:
yarn add {{name}}Using pnpm:
pnpm add {{name}}Using bun:
bun add {{name}}License
See the LICENSE file for license rights and limitations (LGPL-3.0-only).
Reference
packages
decimal-precision
### .temp-typedoc
### functions
### <a id="fromFixedPoint"></a>fromFixedPointfunction fromFixedPoint(value, places?): bigint;Converts a fixed-point bigint back to a whole-number bigint by dividing out the decimal places.
Parameters
value
bigint
The fixed-point bigint value to convert
places?
number = 18
Number of decimal places (default 18)
Returns
bigint
The whole-number bigint result
### <a id="toDecimalPrecision"></a>toDecimalPrecisionfunction toDecimalPrecision(value, digits): string;Formats a number to the specified number of significant digits, returning a string with minimal trailing zeros.
Parameters
value
number
The number to format
digits
number
The number of significant digits
Returns
string
A string representation of the number with the specified precision
### <a id="toFixedPoint"></a>toFixedPointfunction toFixedPoint(value, places?): bigint;Converts a bigint or decimal string to a fixed-point bigint representation.
Parameters
value
string | bigint
The value to convert (bigint or string with optional decimal point)
places?
number = 18
Number of decimal places (default 18)
Returns
bigint
A bigint representing the value scaled by 10^places
