Skip to content

Amount

divide

1.0.0

Divides an amount by a divisor.

amount.divide(/divisor/, <rounding>);
  • Returns a single Amount as result
  • Accepts fractional and whole number parts
  • Excepts dividing by zero or negative numbers, with proper error handling
  • Simple and intuitive API
  • Comprehensive testing
ArgTypeDefault ValueRequired
partsnumber-Yes
roundingmath | bankmathNo

From an initial Amount instance, use the divide() method using a number to divide the amount by that divisor.

import { amount } from '@inpulse-ui/utils';
const result = amount(100.00, 'USD').divide(2);
console.log(result); // Results an AmountArray instance with value 50 USD

This method also accepts fractional divisors (e.g., 2.5 to divide the amount by 2.5).

const result = amount(100.00, 'USD').divide(2.5);
console.log(result); // Results 40 USD

Use divide() when you want to:

  1. Calculate unit prices.

    const unitPrice = totalPrice.divide(quantity); // $127.50 ÷ 5 = $25.50
  2. Reverse calculations (remove tax, etc.)

    const discounted = originalPrice.divide(1.1); // Remove 10% dTax
  3. Perform mathematical division.

    const result = amount.divide(2.5); // 100 ÷ 2.5 = 40

Please refer to the split() method whenever you need to:

  • Split an amount into equal parts.
  • Create equal installments.
  • Distribute money among people.
  • Get an array of Amount instances.

Project

Built with by Jo Santana in Brazil.

© 2026 Inpulse. All rights reserved.