---
title: "fma(): IR builder function in typeshade/core/ir, TypeShade"
description: "fma, an IR builder function in typeshade/core/ir. fma(a, b, c): multiply-add, a·b + c, component-wise for vectors."
url: https://typeshade.dev/api/fma/
language: en
---

# `fma()`

Function in Builtins

`fma(a, b, c)`: multiply-add, a·b + c, component-wise for vectors.

`import { fma } from 'typeshade/core/ir'`

This export returns an IR node. A `"use typeshade"` file calls the builtin itself: [`fma()`](https://typeshade.dev/reference/functions/fma/)

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
const fma: <K extends FloatKey>(
  a: ReadonlyNode<K>,
  b: NoInfer<ArithArg<K>>,
  c: NoInfer<ArithArg<K>>,
) => Node<K>
```

## Parameters

**`a` `ReadonlyNode<K>`**

**`b` `NoInfer<ArithArg<K>>`**

**`c` `NoInfer<ArithArg<K>>`**

## Return value

`Node<K>`

## Description

WGSL emits the `fma` builtin. Its accuracy rules allow an ordinary multiply followed by an ordinary add, so it does not guarantee a single rounding or an exact product error term. GLSL ES 3.00 has no `fma`, so the GLSL output is `(a * b + c)`. That target also permits either one rounding or separate roundings for the product and sum. Neither spelling guarantees identical results across devices or backends.

See [WGSL fma](https://www.w3.org/tr/WGSL/#fma-builtin) and GLSL ES 3.00 section 4.5.1.

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | `fma(a, b, c)`. |
| GLSL ES 3.00 (WebGL2) | Supported | `((a) * (b) + (c))`. |
| CPU oracle | Supported | Evaluated in `f64` by the oracle. |

## See also

- [`fma()`](https://typeshade.dev/reference/functions/fma/)

## Source

[`src/core/ir/node.ts`, line 1489](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1489), at commit af54ddad5
