Summator.opCast

Returns Summator with extended internal partial sums.

  1. C opCast()
    struct Summator(T, Summation summation = Summation.Precise)
    C
    opCast
    (
    C : Summator!P
    P
    )
    ()
    if (
    isMutable!C &&
    P.max_exp >= T.max_exp
    &&
    P.mant_dig >= T.mant_dig
    )
    if (
    isMutable!T &&
    (
    summation == Summation.Precise &&
    isFloatingPoint!T
    ||
    summation == Summation.Kahan &&
    isSummable!T
    ||
    (
    summation == Summation.KBN ||
    summation == Summation.KB2
    )
    &&
    (
    isFloatingPoint!T ||
    isComplex!T
    )
    )
    )
  2. C opCast()

Examples

import std.math;
float  M = 2.0f ^^ (float.max_exp-1);
double N = 2.0  ^^ (float.max_exp-1);
auto s = Summator!float(0); //float summator
s += M;
s += M;
assert(float.infinity == s.sum());
auto e = cast(Summator!double) s;
assert(isFinite(e.sum()));
assert(N+N == e.sum());

Meta