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

    Parameters

    • units: string | bigint
    • totalPrice: string | bigint
    • Optional unitDecimals: number
    • Optional priceDecimals: number
    • Optional noAbs: boolean

      pass true to allow -ve values for resulted unit price

    Returns bigint

    Example

    calcPrice(BigInt(2e6), BigInt(1e5), 6, 6) // 50000n