• Calculates units based on the total price and number of units.

    Parameters

    • totalPrice: string | bigint
    • unitPrice: string | bigint
    • Optional priceDecimals: number
    • Optional unitDecimals: number

    Returns bigint

    Example

    calcUnits(BigInt(1e5), BigInt(2e6)) // 50000000000000000n
    calcUnits('1000', '1200', 2, 2) // 83n === 0.83 * 10^2