JavaScript DataView.getUint32() method

The DataView.getUint32 method in JavaScript is a built-in function associated with the DataView object. This method is utilized to retrieve an unsigned 32-bit integer (unsigned long) value from a specified position within the DataView.

Syntax

Example

dataview.getUint32(byteoffset)

Parameters

byteoffset: The number of bytes from the beginning of the view indicating the position where the data should be read.

Return value

This function outputs an unsigned integer value with a size of 32 bits.

Browser Support

Chrome 9
Safari 5.1
Firefox 15
Opera 12.1

Example 1

Example

<script>

//JavaScript to illustrate dataview.getUint32() method

// creating a ArrayBuffer 

var pyVisualizer = new ArrayBuffer(10);

// creating a view

var arr = new DataView(pyVisualizer);

// put the value 234.2 at slot 1

arr.setUint32(1,234.1);

document.write("Convert the value 234.2 to:<br><br>");

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

//expected output: 234

</script>

Output:

Output

Convert the value 234.2 to:



234

Example 2

Example

<script>

//JavaScript to illustrate dataview.getUint32() 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.setUint32(1);

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

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

//expected output: 0

</script>

Output:

Output

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



0

Example 3

Example

<script>

//JavaScript to illustrate dataview.getUint32() 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

arr.setUint32(1,Math.PI);

document.write("Convert the PI value 3.14 to:<br><br>");

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

//expected output: 3

</script>

Output:

Output

Convert the PI value 3.14 to:



3

Example 4

Example

<script>

//JavaScript to illustrate dataview.getUint32() method

// creating a ArrayBuffer 

var pyVisualizer = new ArrayBuffer(8);

// creating a view

var arr = new DataView(pyVisualizer);

// put the value 123 at slot 1

arr.setUint32(1,123);

document.write("If we give an Integer value then Output will  be Integer<br><br>");

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

//expected output: 123

</script>

Output:

Output

If we give an Integer value then Output will be Integer



123

Input Required

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