Whats the deal in USA with 1 litre soda pop, is USA on metric?

Kahan summation isn’t really related to the non-binariness of ten — if that’s your concern, just multiple all your “mils” (or whatever) by 1000 and work with integers.

But Kahan summation is a beautiful little method! I am perfectionistic enough that I use Kahan’s method, e.g. when calculating statistical moments. One big caveat for the C programmer:



/* Do NOT compile this with any compiler optimization !
 * The optimizer would "figure out" that kp->carry is being set to zero
 * and eliminate the essence of the method!
 */
double kahan_add(double addend, struct Floatsum *kp)
{
        double y = addend - kp->carry;
        double tmp = kp->sum + y;
        kp->carry = (tmp - kp->sum) - y;
        kp->sum = tmp;
        return kp->sum + kp->carry;
}