# mad

> Returns the result of a multiply-add operation (a * b + c) on 3 int values.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Mathematics](/engine/6000.6/script-reference/unity/mathematics.md)
* **Assembly:** UnityEngine.MathematicsModule

## mad(int, int, int)

Returns the result of a multiply-add operation (a \* b + c) on 3 int values.

```csharp
public static int mad(int mulA, int mulB, int addC)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): First value to multiply.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Second value to multiply.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Third value to add to the product of a and b.

### Returns

| Type                                                       | Description                     |
| ---------------------------------------------------------- | ------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The multiply-add of the inputs. |

## mad(int2, int2, int2)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 int2 vectors.

```csharp
public static int2 mad(int2 mulA, int2 mulB, int2 addC)
```

### Parameters

**** (\[int2]\(/engine/6000.6/script-reference/unity/mathematics/int2)): First value to multiply.**** (\[int2]\(/engine/6000.6/script-reference/unity/mathematics/int2)): Second value to multiply.**** (\[int2]\(/engine/6000.6/script-reference/unity/mathematics/int2)): Third value to add to the product of a and b.

### Returns

| Type                                                              | Description                                   |
| ----------------------------------------------------------------- | --------------------------------------------- |
| [int2](/engine/6000.6/script-reference/unity/mathematics/int2.md) | The componentwise multiply-add of the inputs. |

## mad(int3, int3, int3)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 int3 vectors.

```csharp
public static int3 mad(int3 mulA, int3 mulB, int3 addC)
```

### Parameters

**** (\[int3]\(/engine/6000.6/script-reference/unity/mathematics/int3)): First value to multiply.**** (\[int3]\(/engine/6000.6/script-reference/unity/mathematics/int3)): Second value to multiply.**** (\[int3]\(/engine/6000.6/script-reference/unity/mathematics/int3)): Third value to add to the product of a and b.

### Returns

| Type                                                              | Description                                   |
| ----------------------------------------------------------------- | --------------------------------------------- |
| [int3](/engine/6000.6/script-reference/unity/mathematics/int3.md) | The componentwise multiply-add of the inputs. |

## mad(int4, int4, int4)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 int4 vectors.

```csharp
public static int4 mad(int4 mulA, int4 mulB, int4 addC)
```

### Parameters

**** (\[int4]\(/engine/6000.6/script-reference/unity/mathematics/int4)): First value to multiply.**** (\[int4]\(/engine/6000.6/script-reference/unity/mathematics/int4)): Second value to multiply.**** (\[int4]\(/engine/6000.6/script-reference/unity/mathematics/int4)): Third value to add to the product of a and b.

### Returns

| Type                                                              | Description                                   |
| ----------------------------------------------------------------- | --------------------------------------------- |
| [int4](/engine/6000.6/script-reference/unity/mathematics/int4.md) | The componentwise multiply-add of the inputs. |

## mad(uint, uint, uint)

Returns the result of a multiply-add operation (a \* b + c) on 3 uint values.

```csharp
public static uint mad(uint mulA, uint mulB, uint addC)
```

### Parameters

**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): First value to multiply.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Second value to multiply.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Third value to add to the product of a and b.

### Returns

| Type                                                         | Description                     |
| ------------------------------------------------------------ | ------------------------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | The multiply-add of the inputs. |

## mad(uint2, uint2, uint2)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 uint2 vectors.

```csharp
public static uint2 mad(uint2 mulA, uint2 mulB, uint2 addC)
```

### Parameters

**** (\[uint2]\(/engine/6000.6/script-reference/unity/mathematics/uint2)): First value to multiply.**** (\[uint2]\(/engine/6000.6/script-reference/unity/mathematics/uint2)): Second value to multiply.**** (\[uint2]\(/engine/6000.6/script-reference/unity/mathematics/uint2)): Third value to add to the product of a and b.

### Returns

| Type                                                                | Description                                   |
| ------------------------------------------------------------------- | --------------------------------------------- |
| [uint2](/engine/6000.6/script-reference/unity/mathematics/uint2.md) | The componentwise multiply-add of the inputs. |

## mad(uint3, uint3, uint3)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 uint3 vectors.

```csharp
public static uint3 mad(uint3 mulA, uint3 mulB, uint3 addC)
```

### Parameters

**** (\[uint3]\(/engine/6000.6/script-reference/unity/mathematics/uint3)): First value to multiply.**** (\[uint3]\(/engine/6000.6/script-reference/unity/mathematics/uint3)): Second value to multiply.**** (\[uint3]\(/engine/6000.6/script-reference/unity/mathematics/uint3)): Third value to add to the product of a and b.

### Returns

| Type                                                                | Description                                   |
| ------------------------------------------------------------------- | --------------------------------------------- |
| [uint3](/engine/6000.6/script-reference/unity/mathematics/uint3.md) | The componentwise multiply-add of the inputs. |

## mad(uint4, uint4, uint4)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 uint4 vectors.

```csharp
public static uint4 mad(uint4 mulA, uint4 mulB, uint4 addC)
```

### Parameters

**** (\[uint4]\(/engine/6000.6/script-reference/unity/mathematics/uint4)): First value to multiply.**** (\[uint4]\(/engine/6000.6/script-reference/unity/mathematics/uint4)): Second value to multiply.**** (\[uint4]\(/engine/6000.6/script-reference/unity/mathematics/uint4)): Third value to add to the product of a and b.

### Returns

| Type                                                                | Description                                   |
| ------------------------------------------------------------------- | --------------------------------------------- |
| [uint4](/engine/6000.6/script-reference/unity/mathematics/uint4.md) | The componentwise multiply-add of the inputs. |

## mad(long, long, long)

Returns the result of a multiply-add operation (a \* b + c) on 3 long values.

```csharp
public static long mad(long mulA, long mulB, long addC)
```

### Parameters

**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): First value to multiply.**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): Second value to multiply.**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): Third value to add to the product of a and b.

### Returns

| Type                                                        | Description                     |
| ----------------------------------------------------------- | ------------------------------- |
| [long](https://learn.microsoft.com/dotnet/api/system.int64) | The multiply-add of the inputs. |

## mad(ulong, ulong, ulong)

Returns the result of a multiply-add operation (a \* b + c) on 3 ulong values.

```csharp
public static ulong mad(ulong mulA, ulong mulB, ulong addC)
```

### Parameters

**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): First value to multiply.**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): Second value to multiply.**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): Third value to add to the product of a and b.

### Returns

| Type                                                          | Description                     |
| ------------------------------------------------------------- | ------------------------------- |
| [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) | The multiply-add of the inputs. |

## mad(float, float, float)

Returns the result of a multiply-add operation (a \* b + c) on 3 float values.

```csharp
public static float mad(float mulA, float mulB, float addC)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): First value to multiply.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Second value to multiply.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Third value to add to the product of a and b.

### Returns

| Type                                                          | Description                     |
| ------------------------------------------------------------- | ------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | The multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

## mad(float2, float2, float2)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 float2 vectors.

```csharp
public static float2 mad(float2 mulA, float2 mulB, float2 addC)
```

### Parameters

**** (\[float2]\(/engine/6000.6/script-reference/unity/mathematics/float2)): First value to multiply.**** (\[float2]\(/engine/6000.6/script-reference/unity/mathematics/float2)): Second value to multiply.**** (\[float2]\(/engine/6000.6/script-reference/unity/mathematics/float2)): Third value to add to the product of a and b.

### Returns

| Type                                                                  | Description                                   |
| --------------------------------------------------------------------- | --------------------------------------------- |
| [float2](/engine/6000.6/script-reference/unity/mathematics/float2.md) | The componentwise multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

## mad(float3, float3, float3)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 float3 vectors.

```csharp
public static float3 mad(float3 mulA, float3 mulB, float3 addC)
```

### Parameters

**** (\[float3]\(/engine/6000.6/script-reference/unity/mathematics/float3)): First value to multiply.**** (\[float3]\(/engine/6000.6/script-reference/unity/mathematics/float3)): Second value to multiply.**** (\[float3]\(/engine/6000.6/script-reference/unity/mathematics/float3)): Third value to add to the product of a and b.

### Returns

| Type                                                                  | Description                                   |
| --------------------------------------------------------------------- | --------------------------------------------- |
| [float3](/engine/6000.6/script-reference/unity/mathematics/float3.md) | The componentwise multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

## mad(float4, float4, float4)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 float4 vectors.

```csharp
public static float4 mad(float4 mulA, float4 mulB, float4 addC)
```

### Parameters

**** (\[float4]\(/engine/6000.6/script-reference/unity/mathematics/float4)): First value to multiply.**** (\[float4]\(/engine/6000.6/script-reference/unity/mathematics/float4)): Second value to multiply.**** (\[float4]\(/engine/6000.6/script-reference/unity/mathematics/float4)): Third value to add to the product of a and b.

### Returns

| Type                                                                  | Description                                   |
| --------------------------------------------------------------------- | --------------------------------------------- |
| [float4](/engine/6000.6/script-reference/unity/mathematics/float4.md) | The componentwise multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

## mad(double, double, double)

Returns the result of a multiply-add operation (a \* b + c) on 3 double values.

```csharp
public static double mad(double mulA, double mulB, double addC)
```

### Parameters

**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): First value to multiply.**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): Second value to multiply.**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): Third value to add to the product of a and b.

### Returns

| Type                                                           | Description                     |
| -------------------------------------------------------------- | ------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | The multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

## mad(double2, double2, double2)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 double2 vectors.

```csharp
public static double2 mad(double2 mulA, double2 mulB, double2 addC)
```

### Parameters

**** (\[double2]\(/engine/6000.6/script-reference/unity/mathematics/double2)): First value to multiply.**** (\[double2]\(/engine/6000.6/script-reference/unity/mathematics/double2)): Second value to multiply.**** (\[double2]\(/engine/6000.6/script-reference/unity/mathematics/double2)): Third value to add to the product of a and b.

### Returns

| Type                                                                    | Description                                   |
| ----------------------------------------------------------------------- | --------------------------------------------- |
| [double2](/engine/6000.6/script-reference/unity/mathematics/double2.md) | The componentwise multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

## mad(double3, double3, double3)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 double3 vectors.

```csharp
public static double3 mad(double3 mulA, double3 mulB, double3 addC)
```

### Parameters

**** (\[double3]\(/engine/6000.6/script-reference/unity/mathematics/double3)): First value to multiply.**** (\[double3]\(/engine/6000.6/script-reference/unity/mathematics/double3)): Second value to multiply.**** (\[double3]\(/engine/6000.6/script-reference/unity/mathematics/double3)): Third value to add to the product of a and b.

### Returns

| Type                                                                    | Description                                   |
| ----------------------------------------------------------------------- | --------------------------------------------- |
| [double3](/engine/6000.6/script-reference/unity/mathematics/double3.md) | The componentwise multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.

## mad(double4, double4, double4)

Returns the result of a componentwise multiply-add operation (a \* b + c) on 3 double4 vectors.

```csharp
public static double4 mad(double4 mulA, double4 mulB, double4 addC)
```

### Parameters

**** (\[double4]\(/engine/6000.6/script-reference/unity/mathematics/double4)): First value to multiply.**** (\[double4]\(/engine/6000.6/script-reference/unity/mathematics/double4)): Second value to multiply.**** (\[double4]\(/engine/6000.6/script-reference/unity/mathematics/double4)): Third value to add to the product of a and b.

### Returns

| Type                                                                    | Description                                   |
| ----------------------------------------------------------------------- | --------------------------------------------- |
| [double4](/engine/6000.6/script-reference/unity/mathematics/double4.md) | The componentwise multiply-add of the inputs. |

### Remarks

When Burst compiled with fast math enabled on some architectures, this could be converted to a fused multiply add (FMA). FMA is more accurate due to rounding once at the end of the computation rather than twice that is required when this computation is not fused.
