product(_:_:)
The product a * b
represented as an implicit sum head + tail
.
static func product<T>(_ a: T, _ b: T) -> (head: T, tail: T) where T : Real
head
is the correctly rounded value of a*b
. If no overflow or underflow occurs, tail
represents the rounding error incurred in computing head
, such that the exact product is the sum of head
and tail
computed without rounding.
This operation is sometimes called “twoProd” or “twoProduct”.
Edge Cases:
head
is always the IEEE 754 producta * b
.If
head
is not finite,tail
is unspecified and should not be interpreted as having any meaning (it may beNaN
orinfinity
).When
head
is close to the underflow boundary, the rounding error may not be representable due to underflow, andtail
will be rounded. Ifhead
is very small,tail
may even be zero, even though the product is not exact.If
head
is zero,tail
is also a zero with unspecified sign.
Postconditions:
If
head
is normal, thenabs(tail) < head.ulp
. Assuming IEEE 754 default rounding,abs(tail) <= head.ulp/2
.If both
head
andtail
are normal, thena * b
is exactly equal tohead + tail
when computed as real numbers.