Skip to main content

sums_to

Function sums_to 

Source
pub fn sums_to(
    values: impl IntoIterator<Item = f64>,
    target: f64,
    tolerance: f64,
) -> (bool, f64)
Expand description

Whether the values yielded by values sum to target within ± tolerance (percentage points). Returns the computed sum alongside the verdict, since callers reporting a failure need it in their message. A non-finite sum (e.g. one input was NaN) is always false.