subtract method

UcumDecimal subtract(
  1. UcumDecimal other
)

Implementation

UcumDecimal subtract(UcumDecimal other) {
  UcumDecimal result;
  if (negative && !other.negative) {
    result = doAdd(other);
    result.negative = true;
  } else if (!negative && other.negative) {
    result = doAdd(other);
  } else if (negative && other.negative) {
    result = doSubtract(other);
    result.negative = !result.negative;
  } else {
    result = other.doSubtract(this);
    result.negative = !result.negative;
  }
  return result;
}