JavaScript DataView getFloat64() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
Instance method

Definition

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.

Remember
const view = new DataView(new ArrayBuffer(8));
view.setFloat64(0, Math.PI);
view.getFloat64(0);               // 3.141592653589793
view.getFloat64(0) === Math.PI;   // true
view.getUint8(0).toString(16);    // "40"
view.getFloat64(1);               // RangeError

Syntax

Call getFloat64() on a DataView object with a byte position and, if the data is little-endian, true.

JavaScript
dataview.getFloat64(byteOffset)
dataview.getFloat64(byteOffset, littleEndian)
CallWhat it does
view.getFloat64(byteOffset)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

ParameterDescription
byteOffsetWhere 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.
littleEndianOptional. 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 ValueDescription
NumberThe 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
Try It Yourself

How It Works

  1. Precise coordinates. Six decimal places are more digits than a 32-bit float keeps, so each coordinate uses 8 bytes.
  2. Little-endian on both sides. The values were written with true, so getFloat64(offset, true) reads them back in the same order.
  3. A perfect round trip. Because a double is the native Number format, the value read back is identical to the original, and === is true.

Example 2 — The Bit Patterns of 1 and Pi

Look at the bytes of the number 1, then build pi from its raw bytes and decode it with getFloat64().

JavaScript
const view = new DataView(new ArrayBuffer(8));

view.setFloat64(0, 1);
console.log(view.getUint32(0).toString(16) + " " + view.getUint32(4).toString(16));   // 3ff00000 0

view.setUint32(0, 0x400921fb);
view.setUint32(4, 0x54442d18);
console.log(view.getFloat64(0));   // 3.141592653589793
Try It Yourself

How It Works

  1. Look inside the number 1. Written as a double, 1 is 3ff00000 00000000 in hex: the 3ff part is the exponent, and the fraction is all zeros.
  2. Build a double from bytes. Writing the two 32-bit halves 400921fb and 54442d18 places the exact bit pattern of pi in the buffer.
  3. Decode it. getFloat64(0) reads the 8 bytes together and gives 3.141592653589793, the value of Math.PI.

Example 3 — Read a Price That Starts at Byte 4

A 12-byte record holds a 4-byte product id followed by an 8-byte price. DataView reads the price where it is; a Float64Array cannot.

JavaScript
const record = new DataView(new ArrayBuffer(12));
record.setUint32(0, 1042);         // product id
record.setFloat64(4, 19.99);       // price

console.log("id " + record.getUint32(0) + " costs " + record.getFloat64(4));   // id 1042 costs 19.99

try {
  new Float64Array(record.buffer, 4, 1);
} catch (e) {
  console.log("Float64Array at offset 4: " + e.name);   // Float64Array at offset 4: RangeError
}
Try It Yourself

How It Works

  1. An id followed by a price. The record packs a 4-byte id and an 8-byte price into 12 bytes, so the price starts at byte 4.
  2. DataView reads the price anywhere. getFloat64(4) returns 19.99 exactly as it was written.
  3. A Float64Array would need offset 8. Typed arrays of doubles must start at a multiple of 8, so creating one at byte 4 throws a RangeError.

Browser & Runtime Support

getFloat64() has been part of JavaScript since ES2015, when DataView itself was standardised.

✓ ES2015 · Baseline

DataView.prototype.getFloat64()

Works in every modern browser and in Node.js, Deno and Bun. It runs on a normal ArrayBuffer, so no special page setup is needed.

100% Modern browser support
Google Chrome Modern versions · Desktop & Mobile
Full support
Mozilla Firefox Modern versions · Desktop & Mobile
Full support
Apple Safari Modern versions · macOS & iOS
Full support
Microsoft Edge Modern versions · Chromium
Full support
Opera Modern versions
Full support
Samsung Internet Modern versions · Android
Full support
Internet Explorer Retired browser · not tested here
Legacy
Node.js Current releases · checked on Node 24
Supported
Deno Current releases
Supported
Bun Current releases
Supported
getFloat64() All modern engines

Bottom line: Safe to use without a fallback. It also works on a SharedArrayBuffer, but a normal ArrayBuffer is all you need.

Frequently Asked Questions

A normal JavaScript Number decoded from eight bytes in the 64-bit IEEE 754 double format.
No. JavaScript Numbers are 64-bit doubles themselves, so the value comes back exactly as it was stored.
Most likely the byte order is wrong. Try getFloat64(offset, true) if the data was written little-endian, or the other way round.
Eight. offset + 8 must not be greater than the view byteLength, otherwise a RangeError is thrown.
Both read 8 bytes. getFloat64() interprets them as a floating point number, getBigInt64() as a 64-bit whole number returned as a BigInt.

Next: getInt16()

Back to whole numbers: read a signed 2-byte value such as an audio sample.

getInt16() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful