splitF64
On this page

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 26de7be8.

Syntax

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.

Examples

Example

import { splitF64 } from 'typeshade'
const [hi, lo] = splitF64(originLon)
uniformData.set([hi, lo], offsetOfOrigin / 4)

In the guide

See also

Source

src/core/fp64/df64-lib.ts, line 110, at commit 26de7be8

Edit this page Report a problem