---
title: "mul(): IR builder function in typeshade/core/ir, TypeShade"
description: "mul, an IR builder function in typeshade/core/ir. a * b as a free function, for a literal left operand: mul(2, x) emits (2.0 * x)."
url: https://typeshade.dev/api/mul/
language: en
---

# `mul()`

Function in Builtins

a \* b as a free function, for a literal left operand: mul(2, x) emits (2.0 \* x).

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

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

## Syntax

```ts
function mul<E extends string, N extends number>(
  a: ReadonlyNode<E>,
  b: ReadonlyNode<`vec${N}<${E}>`>,
): Node<`vec${N}<${E}>`>;
function mul<K extends string>(a: ReadonlyNode<K>, b: ArithArg<K>): Node<K>;
function mul<K extends string>(a: number, b: ReadonlyNode<K>): Node<K>;
```

## Parameters

**`a` `ReadonlyNode<E>`**

**`b` ``ReadonlyNode<`vec${N}<${E}>`>``**

## Return value

``Node<`vec${N}<${E}>`>``

## Exceptions

**`TypeError`**

both operands are plain numbers.

## Description

Whichever operand is a node types the other. Two bare numbers are rejected.

## Examples

### Example

```ts
import { fn, mul, f32T } from 'typeshade/core/ir'

const doubled = fn('doubled', { x: f32T }, ({ x }) => mul(2, x))
```

## See also

- [`ReadonlyNode`](https://typeshade.dev/api/readonlynode/)
- [`mul`](https://typeshade.dev/api/mul/)

## Source

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