# Function mul_add

Source

    pub fn mul_add(x: f64, a: f64, b: f64) -> f64

🔬This is a nightly-only experimental API. (`core_float_math` #137578)
Expand description

Experimental version of `mul_add` in `core`. See `f64::mul_add` for details.

## §Examples

    #![feature(core_float_math)]

    use core::f64;

    let m = 10.0_f64;
    let x = 4.0_f64;
    let b = 60.0_f64;

    assert_eq!(f64::math::mul_add(m, x, b), 100.0);
    assert_eq!(m * x + b, 100.0);

    let one_plus_eps = 1.0_f64 + f64::EPSILON;
    let one_minus_eps = 1.0_f64 - f64::EPSILON;
    let minus_one = -1.0_f64;

    // The exact result (1 + eps) * (1 - eps) = 1 - eps * eps.
    assert_eq!(
        f64::math::mul_add(one_plus_eps, one_minus_eps, minus_one),
        -f64::EPSILON * f64::EPSILON
    );
    // Different rounding with the non-fused multiply and add.
    assert_eq!(one_plus_eps * one_minus_eps + minus_one, 0.0);

This standalone function is for testing only. It will be stabilized as an inherent method.