parse static method

LexoInteger parse(
  1. String strFull,
  2. LexoNumeralSystem system
)

Implementation

static LexoInteger parse(String strFull, LexoNumeralSystem system) {
  var str = strFull;
  var sign = 1;
  if (identical(strFull.indexOf(system.getPositiveChar()), 0)) {
    str = strFull.substring(1);
  } else if (identical(strFull.indexOf(system.getNegativeChar()), 0)) {
    str = strFull.substring(1);
    sign = -1;
  }
  final mag = List<int>.filled(str.length, 0);
  var strIndex = mag.length - 1;
  for (var magIndex = 0; strIndex >= 0; ++magIndex) {
    mag[magIndex] = system.toDigit(str[strIndex]);
    --strIndex;
  }
  return LexoInteger.make(system, sign, mag);
}