assertIsBinaryFixedPoint

function assertIsBinaryFixedPoint<
    TSignedness,
    TTotalBits,
    TFractionalBits,
>(
    value,
    signedness?,
    totalBits?,
    fractionalBits?,
): asserts value is BinaryFixedPoint<
    TSignedness,
    TTotalBits,
    TFractionalBits
>;

Asserts that value is a BinaryFixedPoint.

Every shape parameter is independently optional. Pass undefined (or simply omit trailing arguments) to leave a given field unconstrained.

Throws SOLANA_ERROR__FIXED_POINTS__SHAPE_MISMATCH if the value does not match the expected shape, or SOLANA_ERROR__FIXED_POINTS__VALUE_OUT_OF_RANGE if the raw bigint does not fit the claimed signedness and total bits.

Type Parameters

Type ParameterDefault type
TSignedness extends SignednessSignedness
TTotalBits extends numbernumber
TFractionalBits extends numbernumber

Parameters

ParameterType
valueunknown
signedness?TSignedness
totalBits?TTotalBits
fractionalBits?TFractionalBits

Returns

asserts value is BinaryFixedPoint<TSignedness, TTotalBits, TFractionalBits>

Example

assertIsBinaryFixedPoint(value);                   // any binary fixed-point
assertIsBinaryFixedPoint(value, 'signed');         // any signed binary
assertIsBinaryFixedPoint(value, 'signed', 16, 15); // fully pinned
assertIsBinaryFixedPoint(value, undefined, 16);    // any binary with totalBits=16

See

On this page