setValueScientific method

void setValueScientific(
  1. String value
)

Implementation

void setValueScientific(String value) {
  final int i = value.indexOf('e');
  final String s = value.substring(0, i);
  final String e = value.substring(i + 1);

  if (Utilities.noString(s) ||
      s == '-' ||
      !Utilities.isDecimal(s) ||
      Utilities.noString(e) ||
      e == '-' ||
      !Utilities.isInteger(e)) {
    throw UcumException("'$value' is not a valid decimal");
  }

  setValueUcumDecimal(s);
  scientific = true;

  // Adjust for exponent
  final int exp = int.parse(e);
  decimal = decimal + exp;
}