The OpenD Programming Language

ieeeMean

Return the value that lies halfway between x and y on the IEEE number line.

Formally, the result is the arithmetic mean of the binary significands of x and y, multiplied by the geometric mean of the binary exponents of x and y. x and y must not be NaN. Note: this function is useful for ensuring O(log n) behaviour in algorithms involving a 'binary chop'.

@trusted pure nothrow @nogc
T
ieeeMean
(
T
)
(
const T xx
,
const T yy
)

Parameters

xx T

x value

yy T

y value

Special cases: If x and y not null and have opposite sign bits, then copysign(T(0), y) is returned. If x and y are within a factor of 2 and have the same sign, (ie, feqrel(x, y) > 0), the return value is the arithmetic mean (x + y) / 2. If x and y are even powers of 2 and have the same sign, the return value is the geometric mean, ieeeMean(x, y) = sgn(x) * sqrt(fabs(x * y)).

Meta