
/**
 * Returns the result of the given floating point expansion rounded to a double
 * floating point number. 
 * 
 * The result is within 1 ulps of the actual value, e.g. imagine the worst case
 * situation where we add (in 4dot4) 1111.1000 + 0.000011111111... The result
 * will be 1111.1000 whereas as the correct result should be 1111.1001 and we
 * thus lost 1 ulp of accuracy. It does not matter that the expansion contain
 * several floats since none is overlapping.
 * 
 * See Shewchuk https://people.eecs.berkeley.edu/~jrs/papers/robustr.pdf
 * 
 * @param e a floating point expansion
 */
function eEstimate(e: number[]) {
    let Q = e[0];
    for (let i=1; i<e.length; i++) {
        Q += e[i];
    }

    return Q;
}


export { eEstimate }
