std-method
Floating-point mul_add
Calculate a product and sum with a single final rounding. This can reduce rounding error in formulas of the form x*a+b. Expected stdout (not executed): 6.5 Common mistake: A fused operation can differ from two separate operations; neither makes every larger formula exact.
Formal Syntax & Structure
rust syntaxrust
x.mul_add(a, b) -> f64Working Example
Example Snippetrust
fn main() { let reading = 3.0_f64; println!("{}", reading.mul_add(2.0, 0.5));}