---
title: "splitF64(): function in Emulated f64, TypeShade API"
description: "splitF64, a function in Emulated f64. Split a JavaScript double into the high and low f32 pair an f64T value carries on the GPU."
url: https://typeshade.dev/api/splitf64/
language: en
---

# `splitF64()`

Function in Emulated `f64`

Split a JavaScript double into the high and low `f32` pair an f64T value carries on the GPU.

`import { splitF64 } from 'typeshade'`

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

## Syntax

```ts
function splitF64(x: number): [hi: number, lo: number]
```

## Parameters

**`x` `number`**

the double to pack.

## Return value

`[hi: number, lo: number]`

the `[hi, lo]` pair, both exactly representable as `f32`.

## Description

`hi` is `Math.fround(x)` and `lo` is `Math.fround(x - hi)`, so `hi + lo` reconstructs `x` to about 48 significand bits.

This is the host side of the packing. An `f64` uniform field or vertex attribute occupies one plain `vec2<f32>` slot, size 8 and align 8, and the host writes `splitF64(value)` into it.

A vertex attribute cannot be a `vecN<f64>`. Pass a vector as two `vecN<f32>` locations, one carrying every high part and one every low part, and rebuild the components in the shader with [`f64FromParts`](https://typeshade.dev/api/f64fromparts/).

## Examples

### Example

```ts
import { splitF64 } from 'typeshade'

const [hi, lo] = splitF64(originLon)
uniformData.set([hi, lo], offsetOfOrigin / 4)
```

## In the guide

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

## See also

- [`f64T`](https://typeshade.dev/api/f64t/)
- [`f64FromParts`](https://typeshade.dev/api/f64fromparts/)

## Source

[`src/core/fp64/df64-lib.ts`, line 75](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/fp64/df64-lib.ts#L75), at commit af54ddad5
