MCPcopy Index your code
hub / github.com/python/cpython / _rshift_nearest

Function _rshift_nearest

Lib/_pydecimal.py:5689–5695  ·  view source on GitHub ↗

Given an integer x and a nonnegative integer shift, return closest integer to x / 2**shift; use round-to-even in case of a tie.

(x, shift)

Source from the content-addressed store, hash-verified

5687 return a
5688
5689def _rshift_nearest(x, shift):
5690 """Given an integer x and a nonnegative integer shift, return closest
5691 integer to x / 2**shift; use round-to-even in case of a tie.
5692
5693 """
5694 b, q = 1 << shift, x >> shift
5695 return q + (2*(x & (b-1)) + (q&1) > b)
5696
5697def _div_nearest(a, b):
5698 """Closest integer to a/b, a and b positive integers; rounds to even

Callers 1

_ilogFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…