Dev Helpers

TypeScript / Binary and numeric data

Project records into a Float32Array

Dev Helpers · June 25, 2026

A Float32Array stores numbers in single precision. Projecting records into it can change a decimal value even when the projected field was a number.

Worked example

type Sample = { time: number; value: number };
const samples: Sample[] = [
  { time: 1, value: 2 },
  { time: 2, value: 6 },
  { time: 4, value: 10 },
];
console.log(Float32Array.from(samples, (s) => s.value).join(","));

Result

2,6,10

Implementation notes

Typed arrays trade flexibility for a fixed element representation. Retain identifiers separately if later work must map numerical positions back to source records.

Try it yourself

Compare a decimal before and after the typed-array conversion.

Open the TypeScript example →

Editorial date June 25, 2026 · Published December 6, 2026

Related articles

Reject fractional cent amounts

A numeric type cannot by itself guarantee whole cents. Validate integrality where money enters the typed part of the application.

Infer route names from a registry

A route registry can drive both lookup and allowed route names. Type the keys from the registry so a removed route cannot survive in a separate union.