Click here for v1.x documentation.
Dinero.js
Dinero.js version

multiply

Dinero<TAmount>

Multiply a Dinero object.

If you need to multiply by a fractional multiplier, you shouldn't use floats, but scaled amounts instead. For example, instead of passing 2.1, you should pass { amount: 21, scale: 1 }. When using scaled amounts, the function converts the returned objects to the safest scale.

Copy linkParameters

NameTypeDescriptionRequired
multiplicandDinero<TAmount>

The Dinero object to multiply.

Yes
multiplierScaledAmount<TAmount> | TAmount

The number to multiply with.

Yes

Copy linkCode examples

Copy linkMultiply by an integer

import { dinero, multiply } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 400, currency: USD });

multiply(d, 4); // a Dinero object with amount 1600

Copy linkMultiply by a scaled multiplier

import { dinero, multiply } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 401, currency: USD });

multiply(d, { amount: 2001, scale: 3 }); // a Dinero object with amount 802401 and scale 5