Skip to content

Amount

isNegative

1.0.0

Checks if an amount is negative (less than zero) by comparing the internal cents value.

amount.isNegative();
  • Returns a boolean value indicating if the amount is negative
  • Compares against the internal cents representation for precision
  • Works with any currency
  • Simple and intuitive API
  • No side effects - read-only operation
  • Comprehensive testing
ArgTypeDefault ValueRequired
No arguments required

From an Amount instance, use the isNegative() method to check if the amount is less than zero.

import { amount } from '@inpulse-ui/utils';
const negativeAmount = amount(-100, 'USD');
const result = negativeAmount.isNegative();
console.log(result); // true

It returns false for zero and positive amounts:

const zeroAmount = amount(0, 'EUR');
const positiveAmount = amount(50, 'GBP');
console.log(zeroAmount.isNegative()); // false
console.log(positiveAmount.isNegative()); // false

Works with decimal values:

const smallNegative = amount(-0.01, 'USD');
const smallPositive = amount(0.01, 'USD');
console.log(smallNegative.isNegative()); // true
console.log(smallPositive.isNegative()); // false

Useful for conditional logic:

const balance = amount(-25.50, 'USD');
if (balance.isNegative()) {
console.log('Account is overdrawn');
} else {
console.log('Account balance is zero or positive');
}
// Output: "Account is overdrawn"

Validation for debt tracking:

const accountBalance = amount(-150.00, 'USD');
if (accountBalance.isNegative()) {
console.log(`Outstanding debt: ${accountBalance.abs().format()}`);
// Handle negative balance
} else {
console.log('No outstanding debt');
}
// Output: "Outstanding debt: $150.00"

Project

Built with by Jo Santana in Brazil.

© 2026 Inpulse. All rights reserved.