MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / MeanUsingAndXor

Function MeanUsingAndXor

math/binary/arithmeticmean.go:14–16  ·  view source on GitHub ↗

MeanUsingAndXor This function finds arithmetic mean using "AND" and "XOR" operations

(a int, b int)

Source from the content-addressed store, hash-verified

12
13// MeanUsingAndXor This function finds arithmetic mean using "AND" and "XOR" operations
14func MeanUsingAndXor(a int, b int) int {
15 return ((a ^ b) >> 1) + (a & b)
16}
17
18// MeanUsingRightShift This function finds arithmetic mean using right shift
19func MeanUsingRightShift(a int, b int) int {

Callers 2

TestMeanUsingAndXorFunction · 0.85
BenchmarkMeanUsingAndXorFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestMeanUsingAndXorFunction · 0.68
BenchmarkMeanUsingAndXorFunction · 0.68