JavaScript DataView.getFloat64() method

The DataView.getFloat64 method in JavaScript is a built-in function of the DataView object. This method retrieves a signed 64-bit floating-point number (also known as a double) from a designated position within the DataView.

NOTE: Range of 64-bit floating point number is from -1.7+308 to +1.7E+308.

Syntax

Example

dataview.getFloat64(byteOffset)

Parameters

byteoffset: This denotes the position, measured in bytes, from the beginning of the view at which the data should be accessed.

Return value

A signed 64-bit float number.

Browser Support

Chrome 9
Safari 5.1
Firefox 15
Opera 12.1

Example 1

Example

<script>

//JavaScript to illustrate dataview.getFloat64() method

// creating a ArrayBuffer 

var pyVisualizer = new ArrayBuffer(20);

// Creating a view

var arr = new DataView(pyVisualizer);

// put the value 5.7 at slot 1

arr.setFloat64(1,5.7);

document.write("If we give a Float value then output will be<br><br>");

document.write(arr.getFloat64(1));

//expected output:5.7

</script>

Output:

Output

If we give a Float value then output will be

5.7

Example 2

Example

<script>

//JavaScript to illustrate dataview.getFloat64() method

// if there is no data to be stored then it returns Nan

// creating a ArrayBuffer 

var pyVisualizer = new ArrayBuffer(10);

// creating a view

var arr = new DataView(pyVisualizer);

// NO Data

arr.setFloat64(1);

document.write(" if there is no data to be stored, then Output will Be:<br><br>")

document.write(arr.getFloat64(1));

//expected output:NAN

</script>

Output:

Output

if there is no data to be stored, then Output will Be:



NaN

Example 3

Example

<script>

//JavaScript to illustrate dataview.getFloat64() method

// creating a ArrayBuffer

var pyVisualizer = new ArrayBuffer(10);

// creating a view

var arr = new DataView(pyVisualizer);

//We can also use math function like Math.PI

document.write("PI value will be<br><br>");

arr.setFloat64(1,Math.PI);

document.write(arr.getFloat64(1));

//expected output: 3.141592653589793

</script>

Output:

Output

PI value will be

3.141592653589793

Input Required

This code uses input(). Please provide values below: