Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Sharon Christine

The getFloat32() function of the DataView gets and returns a signed 32-bit floating point number at the specified position.

Syntax

Its syntax is as follows

dataView.getFloat32();

Example

Try the following example.

Live Demo

<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <script type="text/javascript">
         var arrayBuffer = new ArrayBuffer(8);
         var dataView = new DataView(arrayBuffer);
         dataView.setFloat32(1, Math.LOG2E);
         document.write(dataView.getFloat32(1));
      </script>
   </body>
</html>

Output

1.4426950216293335

Example

To this function, in addition to floating point values you can also pass Math functions.

Live Demo

<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <script type="text/javascript">
         var arrayBuffer = new ArrayBuffer(8);
         var dataView = new DataView(arrayBuffer);
         dataView.setFloat32(1, Math.LOG2E);
         document.write(dataView.getFloat32(1));
      </script>
   </body>
</html>

Output

1.4426950216293335

Example

If nothing is stored in the dataview and if you still, try to get data this function will return NaN.

Live Demo

<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <script type="text/javascript">
         var arrayBuffer = new ArrayBuffer(8);
         var dataView = new DataView(arrayBuffer);
         dataView.setFloat32(1);
         document.write(dataView.getFloat32(1));
      </script>
   </body>
</html>

Output

NaN

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.