---
title: "toF32(): IR builder function in typeshade/core/ir, TypeShade"
description: "toF32, an IR builder function in typeshade/core/ir. Convert to f32. On an f64 argument this is the explicit, precision-losing narrow…"
url: https://typeshade.dev/api/tof32/
language: en
---

# `toF32()`

Function in Builtins

Convert to `f32`. On an `f64` argument this is the explicit, precision-losing narrow, computed as the sum of the hi and lo halves; `f64` never narrows implicitly.

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

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

## Syntax

```ts
const toF32: (x: ReadonlyNode<string> | number) => Node<"f32">
```

## Parameters

**`x` `ReadonlyNode<string> | number`**

## Return value

`Node<'f32'>`

## Description

Emits `f32(x)` on WGSL and `float(x)` on GLSL.

## Targets

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

## Source

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