MCPcopy Index your code
hub / github.com/RustPython/RustPython / _rshift_nearest

Function _rshift_nearest

Lib/_pydecimal.py:5686–5692  ·  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

5684 return a
5685
5686def _rshift_nearest(x, shift):
5687 """Given an integer x and a nonnegative integer shift, return closest
5688 integer to x / 2**shift; use round-to-even in case of a tie.
5689
5690 """
5691 b, q = 1 << shift, x >> shift
5692 return q + (2*(x & (b-1)) + (q&1) > b)
5693
5694def _div_nearest(a, b):
5695 """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