MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _div_nearest

Function _div_nearest

tools/python-3.11.9-amd64/Lib/_pydecimal.py:5730–5736  ·  view source on GitHub ↗

Closest integer to a/b, a and b positive integers; rounds to even in the case of a tie.

(a, b)

Source from the content-addressed store, hash-verified

5728 return q + (2*(x & (b-1)) + (q&1) > b)
5729
5730def _div_nearest(a, b):
5731 """Closest integer to a/b, a and b positive integers; rounds to even
5732 in the case of a tie.
5733
5734 """
5735 q, r = divmod(a, b)
5736 return q + (2*r + (q&1) > b)
5737
5738def _ilog(x, M, L = 8):
5739 """Integer approximation to M*log(x/M), with absolute error boundable

Callers 7

_ilogFunction · 0.85
_dlog10Function · 0.85
_dlogFunction · 0.85
getdigitsMethod · 0.85
_iexpFunction · 0.85
_dexpFunction · 0.85
_dpowerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected