---
title: "pack2x16float(): IR builder function in typeshade/core/ir"
description: "pack2x16float, an IR builder function in typeshade/core/ir. Pack a vec2<f32> into a u32 as two IEEE-754 binary16 (half) values, component 0 in the 16 low bits."
url: https://typeshade.dev/api/pack2x16float/
language: en
---

# `pack2x16float()`

Function in Builtins

Pack a `vec2<f32>` into a `u32` as two IEEE-754 binary16 (half) values, component 0 in the 16 low bits.

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

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

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

## Syntax

```ts
const pack2x16float: (v: ReadonlyNode<"vec2<f32>">) => Node<"u32">
```

## Parameters

**`v` `ReadonlyNode<'vec2<f32>'>`**

## Return value

`Node<'u32'>`

## Description

Native on both targets (WGSL `pack2x16float`, GLSL ES 3.00 `packHalf2x16`); a value outside binary16’s finite range (`|x| > 65504`) overflows to ±∞ per IEEE conversion. A compact carrier for a pair where 8-bit unorm quantisation is too coarse and two full `f32` components are too wide; [`unpack2x16float`](https://typeshade.dev/api/unpack2x16float/) restores the rounded pair.

## Examples

### Example

```ts
import { fn, pack2x16float, vec2fT } from 'typeshade/core/ir'

const packed = fn('packed', { hv: vec2fT }, ({ hv }) => pack2x16float(hv))
```

## Targets

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

## See also

- [`pack2x16float()`](https://typeshade.dev/reference/functions/pack2x16float/)
- [`unpack2x16float`](https://typeshade.dev/api/unpack2x16float/)

## Source

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