decimalFixedPointToNumber

function decimalFixedPointToNumber(value): number;

Converts a DecimalFixedPoint to a JavaScript number.

This conversion is inherently lossy: 1 / 10 ** decimals is not representable exactly in IEEE 754 for any positive decimals, and additional precision is lost when |value.raw| exceeds Number.MAX_SAFE_INTEGER, since JavaScript numbers have only ~53 bits of mantissa.

For exact representations prefer decimalFixedPointToString.

Parameters

ParameterType
valueDecimalFixedPoint<Signedness, number, number>

Returns

number

Example

const usdc = decimalFixedPoint('unsigned', 64, 6);
decimalFixedPointToNumber(usdc('42.5')); // 42.5

See

decimalFixedPointToString

On this page