In my use of
\numexpr's integer division
/ I have never gotten any advantage from the fact that it rounds rather than truncates.
If we were dealing with floating point numbers, I could understand. But here the operations are on integers. Again, any time this has been an issue for me in coding, always and systematically the "rounding" was a nuisance and generated extra coding to get around it.
Is there any reason rounding has been preferred to truncating?
To be completely honest, I must report there was finally one occasion when I exploited the rounding feature: in the
\xintDSRr macro of
xint 1.2i (2016/12/13). This is a macro which given a (long) integer
N/10 rounded away from zero (i.e. it extends the
\numexpr to big integers). The macro is mainly there for internal use by
\xintiiDivRound which is the general macro computing the rounding to an integer of general (big) fractions
N/M. In all the thousands of lines of
xint, with zillions of use of
\numexpr, I think this is about the only place where I felt happy that the
/ operator rounds inside
\numexpr. In view of what these macros do, it is not that surprising!
On the confirmation of bad experience, but I have now forgotten the precise details, I think I got particularly annoyed once by the fact that when doing a "scaling" operation
a*b/c where the product can be double-word without raising arithmetic overflow, the division is rounding. I think I wanted to use it for
c a power of ten, and if it had been truncating I could have sped up some core algorithms in
xint, but I only have left in memory transient feelings, I forgot the details.