Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Float64Array: 64-bit floating-point values

Float64Array stores Number values in the 64-bit IEEE 754 format, using 8 bytes per element.

Version: ECMAScript 2015 onward; example target: Node.js 24.22.2

Syntax

new Float64Array(); new Float64Array(length); new Float64Array(source); new Float64Array(buffer[, byteOffset[, length]])

new Float64Array(source?, byteOffset?, length?) creates a numeric typed array from a length, iterable/array-like value, another numeric typed array, or a buffer. The ArrayBuffer or SharedArrayBuffer form shares bytes without copying. byteOffset must be a multiple of 8, and BYTES_PER_ELEMENT is 8.

An ordinary JavaScript Number already uses binary64, so assignment does not add rounding to a narrower precision. Only 53 bits of integer precision remain available: the expression 2 ** 53 + 1 is already rounded before storage. NaN, infinities, and -0 are preserved; assigning a BigInt or using a BigInt typed array as source throws TypeError.

Length uses ToIndex, so fractions truncate, NaN/undefined become 0, and -0.5 gives 0. A negative result after ToIntegerOrInfinity, infinity, a misaligned offset, or a range beyond the buffer throws RangeError; a detached buffer throws TypeError. Byte order is native. The type has been standard since ECMAScript 2015.

Examples

const values = new Float64Array([0.1, Number.MAX_VALUE, Number.MIN_VALUE, -0]);
console.log(values[0] === 0.1, values[1] === Number.MAX_VALUE, values[2] === Number.MIN_VALUE);
console.log(Object.is(values[3], -0));

const integers = new Float64Array([2 ** 53, 2 ** 53 + 1]);
console.log(integers[0], integers[1], integers[0] === integers[1]);
console.log(Float64Array.BYTES_PER_ELEMENT, new Float64Array(2.9).length);
try { new Float64Array(new BigInt64Array([1n])); } catch (error) { console.log(error instanceof TypeError); }

Result

true true true
true
9007199254740992 9007199254740992 true
8 2
true

Sources