I ran the code
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\int_new:N\l_rand
\int_step_inline:nn{50}{
\int_set:Nn\l_rand{\int_rand:n{56}}
\int_show:n{\l_rand+(\l_rand-1)/(8-1)}
}
\end{document}
with xetex. In my log shows
> \l_rand +(\l_rand -1)/(8-1)=64.
<recently read> }
which is absurd. Obviously 56+(56-1)/(8-1)=63 and it can't get anywhere larger, so the 64 is a miscalculation. Indeed 55/7 is near 8 so this is probably due to the error of floating point calculation.
So how can I make tex avoid such errors.

l3intstates,/rounds to the nearest integer. No error, that's how it is supposed to work. Use\int_div_truncate:nn{\l_rand-1}{8-1}instead if you need truncated division. – Qrrbrbirlbel Dec 27 '22 at 03:49