add method

LogicalCalculation add(
  1. num val
)

加法运算

Implementation

LogicalCalculation add(num val) {
  if (val is double) {
    final numStr = val.toString();
    final len = numStr.lastIndexOf('.');
    if (len > 0) {
      int base = 1;
      if (len > _point) {
        base = int.parse(pow(10, len).toString());
        _point = len;
      } else {
        base = int.parse(pow(10, _point).toString());
      }
      _total = (_total * base + val * base) / base;
    } else {
      _total += val;
    }
  } else {
    _total += val;
  }
  return this;
}