modulo method

UcumDecimal modulo(
  1. UcumDecimal other
)

Implementation

UcumDecimal modulo(UcumDecimal other) {
  if (other.isZero()) {
    throw UcumException('Modulo by zero');
  }

  final UcumDecimal divisionResult = divide(other);
  final UcumDecimal truncatedResult = divisionResult.trunc();
  return subtract(truncatedResult.multiply(other));
}