idiv method

  1. @override
XPathInteger idiv(
  1. XPathNumeric other
)
override

Implementation

@override
XPathInteger idiv(XPathNumeric other) => switch (other) {
  final XPathInteger i =>
    i.value == BigInt.zero
        ? throw XPathEvaluationException(
            XPathErrorCode.FOAR0001,
            'Division by zero',
          )
        : XPathInteger(value ~/ i.value),
  final XPathDecimal d => toDecimal().idiv(d),
  final XPathDouble d =>
    d.value == 0
        ? throw XPathEvaluationException(
            XPathErrorCode.FOAR0001,
            'Division by zero in idiv',
          )
        : d.value.isNaN
        ? throw XPathEvaluationException(
            XPathErrorCode.FOAR0002,
            'NaN in idiv',
          )
        : d.value.isInfinite
        ? XPathInteger(BigInt.zero)
        : XPathDouble(toDouble()).idiv(d),
};