MoreMathMidpoint Method

Computes the midpoint of two integers.

Definition

Namespace: Meta.Numerics
Assembly: Meta.Numerics (in Meta.Numerics.dll) Version: 4.2.0+6d77d64445f7d5d91b12e331399c4362ecb25333
C#
public static int Midpoint(
	int x,
	int y
)

Parameters

x  Int32
One integer.
y  Int32
Another integer.

Return Value

Int32
The midpoint of the two integers (rounded down).

Remarks

The simple expression (x + y)/2 can overflow. The implementation of this method returns the accurate midpoint for all values of x and y, including all combinations of their extreme values.

See Also