idiv method
Implementation
@override
XPathInteger idiv(XPathNumeric other) {
final otherD = other.toDouble();
if (otherD == 0.0) {
throw XPathEvaluationException(
XPathErrorCode.FOAR0001,
'Division by zero in idiv',
);
}
if (value.isNaN || otherD.isNaN || value.isInfinite) {
throw XPathEvaluationException(
XPathErrorCode.FOAR0002,
'Invalid operand in idiv',
);
}
if (otherD.isInfinite) {
return XPathInteger(BigInt.zero);
}
final quotient = value / otherD;
if (quotient.isNaN ||
quotient.isInfinite ||
quotient.abs() > 9223372036854775807.0) {
throw XPathEvaluationException(
XPathErrorCode.FOAR0002,
'Overflow in idiv',
);
}
return XPathInteger(BigInt.from(value ~/ otherD));
}