binaryFixedPointToNumber

function binaryFixedPointToNumber(value): number;

Converts a BinaryFixedPoint to a JavaScript number.

Precision loss occurs only when |value.raw / 2 ** fractionalBits| exceeds Number.MAX_SAFE_INTEGER, since JavaScript numbers have only ~53 bits of mantissa. For values whose magnitude fits that budget the result is exact, regardless of the raw value's magnitude.

For exact representations prefer binaryFixedPointToString.

Parameters

ParameterType
valueBinaryFixedPoint<Signedness, number, number>

Returns

number

Example

const q1_15 = binaryFixedPoint('signed', 16, 15);
binaryFixedPointToNumber(q1_15('0.5')); // 0.5

See

binaryFixedPointToString

On this page