import std.math, std.numeric; assert(sumOfLog2s(new double[0]) == 0); assert(sumOfLog2s([0.0L]) == -real.infinity); assert(sumOfLog2s([-0.0L]) == -real.infinity); assert(sumOfLog2s([2.0L]) == 1); assert(sumOfLog2s([-2.0L]).isNaN()); assert(sumOfLog2s([real.nan]).isNaN()); assert(sumOfLog2s([-real.nan]).isNaN()); assert(sumOfLog2s([real.infinity]) == real.infinity); assert(sumOfLog2s([-real.infinity]).isNaN()); assert(sumOfLog2s([ 0.25, 0.25, 0.25, 0.125 ]) == -9);
Computes accurate sum of binary logarithms of input range r.