# [−][src]Trait num::traits::ops::mul_add::MulAdd

    pub trait MulAdd<A = Self, B = Self> {
        type Output;
        fn mul_add(self, a: A, b: B) -> Self::Output;
    }

Fused multiply-add. Computes `(self * a) + b` with only one rounding error, yielding a more accurate result than an unfused multiply-add.

Using `mul_add` can be more performant than an unfused multiply-add if the target architecture has a dedicated `fma` CPU instruction.

Note that `A` and `B` are `Self` by default, but this is not mandatory.

# Example

    use std::f32;

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

    // 100.0
    let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();

    assert!(abs_difference <= f32::EPSILON);

## Associated Types

### `type Output`

The resulting type after applying the fused multiply-add.

Loading content...

## Required methods

### `fn mul_add(self, a: A, b: B) -> Self::Output`

Performs the fused multiply-add operation.

Loading content...

## Implementations on Foreign Types

### `impl MulAdd<i16, i16> for i16`[src]

#### `type Output = i16`

#### `fn mul_add(self, a: i16, b: i16) -> <i16 as MulAdd<i16, i16>>::Output`[src]

### `impl MulAdd<i128, i128> for i128`[src]

#### `type Output = i128`

#### `fn mul_add(self, a: i128, b: i128) -> <i128 as MulAdd<i128, i128>>::Output`[src]

### `impl MulAdd<i64, i64> for i64`[src]

#### `type Output = i64`

#### `fn mul_add(self, a: i64, b: i64) -> <i64 as MulAdd<i64, i64>>::Output`[src]

### `impl MulAdd<f64, f64> for f64`[src]

#### `type Output = f64`

#### `fn mul_add(self, a: f64, b: f64) -> <f64 as MulAdd<f64, f64>>::Output`[src]

### `impl MulAdd<usize, usize> for usize`[src]

#### `type Output = usize`

#### `fn mul_add(self, a: usize, b: usize) -> <usize as MulAdd<usize, usize>>::Output`[src]

### `impl MulAdd<u128, u128> for u128`[src]

#### `type Output = u128`

#### `fn mul_add(self, a: u128, b: u128) -> <u128 as MulAdd<u128, u128>>::Output`[src]

### `impl MulAdd<i8, i8> for i8`[src]

#### `type Output = i8`

#### `fn mul_add(self, a: i8, b: i8) -> <i8 as MulAdd<i8, i8>>::Output`[src]

### `impl MulAdd<u64, u64> for u64`[src]

#### `type Output = u64`

#### `fn mul_add(self, a: u64, b: u64) -> <u64 as MulAdd<u64, u64>>::Output`[src]

### `impl MulAdd<u16, u16> for u16`[src]

#### `type Output = u16`

#### `fn mul_add(self, a: u16, b: u16) -> <u16 as MulAdd<u16, u16>>::Output`[src]

### `impl MulAdd<u8, u8> for u8`[src]

#### `type Output = u8`

#### `fn mul_add(self, a: u8, b: u8) -> <u8 as MulAdd<u8, u8>>::Output`[src]

### `impl MulAdd<f32, f32> for f32`[src]

#### `type Output = f32`

#### `fn mul_add(self, a: f32, b: f32) -> <f32 as MulAdd<f32, f32>>::Output`[src]

### `impl MulAdd<u32, u32> for u32`[src]

#### `type Output = u32`

#### `fn mul_add(self, a: u32, b: u32) -> <u32 as MulAdd<u32, u32>>::Output`[src]

### `impl MulAdd<isize, isize> for isize`[src]

#### `type Output = isize`

#### `fn mul_add(self, a: isize, b: isize) -> <isize as MulAdd<isize, isize>>::Output`[src]

### `impl MulAdd<i32, i32> for i32`[src]

#### `type Output = i32`

#### `fn mul_add(self, a: i32, b: i32) -> <i32 as MulAdd<i32, i32>>::Output`[src]

Loading content...

## Implementors

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)