multiplyDecimalFixedPoint

function multiplyDecimalFixedPoint<TSignedness, TTotalBits, TDecimals>(
    a,
    b,
    rounding?,
): DecimalFixedPoint<TSignedness, TTotalBits, TDecimals>;

Multiplies a DecimalFixedPoint by a scalar.

The second operand may be another DecimalFixedPoint with the same signedness (any total bits or decimals) or a bare bigint. The result always has a's shape.

Multiplication by a same-kind fixed-point rescales the product back to a's scale. When that rescaling is not exact, the optional RoundingMode is consulted; it defaults to 'strict' and throws SOLANA_ERROR__FIXED_POINTS__STRICT_MODE_PRECISION_LOSS in that case.

Type Parameters

Type Parameter
TSignedness extends Signedness
TTotalBits extends number
TDecimals extends number

Parameters

ParameterType
aDecimalFixedPoint<TSignedness, TTotalBits, TDecimals>
b| bigint | DecimalFixedPoint<NoInfer<TSignedness>, number, number>
rounding?RoundingMode

Returns

DecimalFixedPoint<TSignedness, TTotalBits, TDecimals>

Example

const usd = decimalFixedPoint('unsigned', 64, 2);
const rate = decimalFixedPoint('unsigned', 64, 4);
multiplyDecimalFixedPoint(usd('100'), rate('0.0025')); // represents 0.25
multiplyDecimalFixedPoint(usd('1.50'), 3n);             // represents 4.50

See

divideDecimalFixedPoint

On this page