Closest integer to a/b, a and b positive integers; rounds to even in the case of a tie.
(a, b)
| 5695 | return q + (2*(x & (b-1)) + (q&1) > b) |
| 5696 | |
| 5697 | def _div_nearest(a, b): |
| 5698 | """Closest integer to a/b, a and b positive integers; rounds to even |
| 5699 | in the case of a tie. |
| 5700 | |
| 5701 | """ |
| 5702 | q, r = divmod(a, b) |
| 5703 | return q + (2*r + (q&1) > b) |
| 5704 | |
| 5705 | def _ilog(x, M, L = 8): |
| 5706 | """Integer approximation to M*log(x/M), with absolute error boundable |