sumOfLog2s

Computes accurate sum of binary logarithms of input range r.

ElementType!Range
sumOfLog2s
(
Range
)
(
Range r
)
if (
isInputRange!Range &&
isFloatingPoint!(ElementType!Range)
)

Examples

1 import std.math, std.numeric;
2 assert(sumOfLog2s(new double[0]) == 0);
3 assert(sumOfLog2s([0.0L]) == -real.infinity);
4 assert(sumOfLog2s([-0.0L]) == -real.infinity);
5 assert(sumOfLog2s([2.0L]) == 1);
6 assert(sumOfLog2s([-2.0L]).isNaN());
7 assert(sumOfLog2s([real.nan]).isNaN());
8 assert(sumOfLog2s([-real.nan]).isNaN());
9 assert(sumOfLog2s([real.infinity]) == real.infinity);
10 assert(sumOfLog2s([-real.infinity]).isNaN());
11 assert(sumOfLog2s([ 0.25, 0.25, 0.25, 0.125 ]) == -9);

Meta