getFloat64() reads eight bytes from a DataView as a 64-bit floating point number (double precision) and returns it as a Number. This is exactly the format JavaScript uses for all its Numbers, so nothing is rounded on the way: you get about 15 to 17 significant digits and a range up to about 1.8 × 10308. It reads big-endian by default; pass true for little-endian.
Reads the 8 bytes starting at byteOffset in big-endian order (most significant byte first) and returns a 64-bit floating point number (double precision).
view.getFloat64(byteOffset, true)
Reads the same 8 bytes in little-endian order (least significant byte first), the order used by most file formats from PCs, such as WAV and BMP.
Part of the original DataView from ES2015, so every modern browser and runtime has it. Unlike a Float64Array, a DataView has no alignment rule: getFloat64() works at any byte position, even one that is not a multiple of 8.
Library declarations
JavaScript
DataView.prototype.getFloat64(byteOffset)
DataView.prototype.getFloat64(byteOffset, littleEndian)
// returns a Number: about -1.7976931348623157e308 to 1.7976931348623157e308, about 15 to 17 significant digits
// reads 8 bytes starting at byteOffset (counted from the start of the view)
// needs byteOffset + 8 <= view.byteLength, else RangeError
// littleEndian: false or left out = big-endian
Parameters
Parameter
Description
byteOffset
Where to start reading, counted in bytes from the start of the view (not of the underlying buffer). It is converted to a whole number, so 1.9 means 1 and "2" means 2. All 8 bytes must fit: byteOffset + 8 may not be larger than view.byteLength. A negative or too-large offset throws a RangeError.
littleEndian
Optional. Leave it out (or pass false) for big-endian: the most significant of the 8 bytes comes first. Pass true for little-endian: the least significant byte comes first. Any truthy value, such as 1, also means little-endian.
Return Value
Return Value
Description
Number
The 8 bytes decoded as a 64-bit floating point number (double precision) and turned into a normal JavaScript Number (range about -1.7976931348623157e308 to 1.7976931348623157e308, about 15 to 17 significant digits). It can also be NaN, Infinity, -Infinity or -0.
JavaScript Examples
Example 1 — Read Precise Coordinates as Doubles
Save the position of the Eiffel Tower as two little-endian doubles and read it back exactly.
JavaScript
const point = new DataView(new ArrayBuffer(16));
point.setFloat64(0, 48.858844, true); // latitude
point.setFloat64(8, 2.294351, true); // longitude
const lat = point.getFloat64(0, true);
const lon = point.getFloat64(8, true);
console.log(lat + ", " + lon); // 48.858844, 2.294351
console.log(lat === 48.858844); // true