sum(large:small:)

The sum a + b represented as an implicit sum head + tail.

AugmentedArithmetic.swift:90
static func sum<T>(large a: T, small b: T) -> (head: T, tail: T) where T : Real

Parameters

a

The summand with larger magnitude.

b

The summand with smaller magnitude.

head is the correctly rounded value of a + b. tail is the error from that computation rounded to the closest representable value.

Unlike Augmented.product(a, b), the rounding error of a sum can never underflow. However, it may not be exactly representable when a and b differ widely in magnitude.

This operation is sometimes called “fastTwoSum”.

Preconditions:

  • large.magnitude must not be smaller than small.magnitude. They may be equal, or one or both may be NaN. This precondition is only enforced in debug builds.

Edge Cases:

  • head is always the IEEE 754 sum a + b.

  • If head is not finite, tail is unspecified and should not be interpreted as having any meaning (it may be NaN or infinity).

Postconditions:

  • If head is normal, then abs(tail) < head.ulp. Assuming IEEE 754 default rounding, abs(tail) <= head.ulp/2.