div property Null safety

NormalOperation div
final

Implementation

static final NormalOperation div = NormalOperation.differentFloatAndInt(
    floatCalc: (Model m) {
      final x = m.xF;
      if (x == 0) {
        throw CalculatorError(0);
      }
      m.floatOverflow = false;
      m.popSetResultXF = m.yF / x;
    },
    intCalc: (Model m) {
      try {
        final BigInt yi = m.yI;
        final BigInt xi = m.xI;
        _storeMultDiv(yi ~/ xi, m);
        // On one emulator I tried, -32768 / -1 resulted in Error 0
        // in 2-16 mode.  But 0 with overflow set is the right answer,
        // and that's what this gives, so I kept it.
        m.cFlag = yi.remainder(xi) != BigInt.zero;
        // ignore: avoid_catches_without_on_clauses
      } catch (e) {
        throw CalculatorError(0);
      }
    },
    name: '/');