---
title: "sign(): IR builder function in typeshade/core/ir, TypeShade"
description: "sign, an IR builder function in typeshade/core/ir. sign(x): -1, 0 or 1 per component, according to the sign of x."
url: https://typeshade.dev/api/sign/
language: en
---

# `sign()`

Function in Builtins

`sign(x)`: -1, 0 or 1 per component, according to the sign of x.

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

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

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

## Syntax

```ts
const sign: <K extends "i32" | FloatKey | `vec${number}<i32>`>(
  x: ReadonlyNode<K>,
) => Node<K>
```

## Parameters

**`x` `ReadonlyNode<K>`**

## Return value

`Node<K>`

## Examples

### Example

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

const dir = fn('dir', { x: f32T }, ({ x }) => sign(x))
```

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | `sign(x)`. |
| GLSL ES 3.00 (WebGL2) | Supported | `sign(x)`. |
| CPU oracle | Supported | Evaluated in `f64` by the oracle. |

## In the guide

- [The CPU oracle](https://typeshade.dev/guide/internals/the-cpu-oracle/)

## See also

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

## Source

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