From a code review:
suspect idiv is/has been broken. This xpath spec says (a idiv b) is equivilent to (a div b) cast as an xs:integer. So I would either expect this to be RoundingMode.FLOOR here, or have some code elsewhere that inserts a cast to integer, but I don't see that. There also do not appear to be any tests for idiv, so I wouldn't be surprised if this is broken.