trunc method

UcumDecimal trunc()

Implementation

UcumDecimal trunc() {
  if (isZero() || decimal <= 0) {
    return zero();
  }

  final UcumDecimal result = copy();

  if (result.digits.length >= result.decimal) {
    result.digits = result.digits.substring(0, result.decimal);
  }
  if (Utilities.noString(result.digits)) {
    result.digits = '0';
    result.decimal = 1;
    result.negative = false;
  }
  return result;
}