What is DataView.getFloat64() in JavaScript?

The DataView.getFloat64() function returns the value of the 64-bit floating-point number stored at the specified position in a DataView object.

This function was added to the DataView object in the ECMAScript 2015 (ES6) standard. It replaces the old getFloat32() and getFloat64() functions, which returned the value of the 32-bit and 64-bit floating-point numbers, respectively.

The getFloat64() function can be used to get the value of a floating-point number that is too large or too small to be stored in a JavaScript number.

The following code sample demonstrates how to use the getFloat64() function to get the value of a floating-point number that is too large to be stored in a JavaScript number.

var data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
var view = new DataView(data);
console.log(view.getFloat64(0)); // 100
console.log(view.getFloat64(1)); // 200
console.log(view.getFloat64(2)); // 300
console.log(view.getFloat64(3)); // 400
console.log(view.getFloat64(4)); // 500
console.log(view.getFloat64(5)); // 600
console.log(view.getFloat64(6)); // 700
console.log(view.getFloat64(7)); // 800
console.log(view.getFloat64(8)); // 900
console.log(view.getFloat64(9)); // 1000
console.log(view.getFloat64(10)); // 1100

The following code sample demonstrates how to use the getFloat64() function to get the value of a floating-point number that is too small to be stored in a JavaScript number.

var data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
var view = new DataView(data);
console.log(view.getFloat64(0)); // 0
console.log(view.getFloat64(1)); // 1
console.log(view.getFloat64(2)); // 2
console.log(view.getFloat64(3)); // 3
console.log(view.getFloat64(4)); // 4
console.log(view.getFloat64(5)); // 5
console.log(view.getFloat64(6)); // 6
console.log(view.getFloat64(7)); // 7
console.log(view.getFloat64(8)); // 8
console.log(view.getFloat64(9)); // 9
console.log(view.getFloat64(10)); // 10
💡
Need a writer? Want to work with me? I have a subscription copywriting service available at Zipply.io. Subscribe to a set number of words and split it into as many copy assets as you need. Scale your startup, small business, or MVP. Upgrade, downgrade and pause at any time. Start your subscription here.