asUcumDecimal method

String asUcumDecimal()

Implementation

String asUcumDecimal() {
  String result = digits;
  if (decimal != digits.length) {
    if (decimal < 0) {
      result = '0.${'0' * (0 - decimal)}$digits';
    } else if (decimal < result.length) {
      if (decimal == 0) {
        result = '0.$result';
      } else {
        result =
            '${result.substring(0, decimal)}.${result.substring(decimal)}';
      }
    } else {
      result = result + '0' * (decimal - result.length);
    }
  }
  if (negative && result != '0') {
    result = '-$result';
  }
  return result;
}