JavaScript DataView.getInt16()

The JavaScript DataView.getInt16() method inserts a signed 16-bit integer number at a specified location.

Range of for unsigned 16-bit integer number:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
0 to 65,535
0 to 65,535
0 to 65,535

Range of for signed 16-bit integer number:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
32,768 to 32,767
32,768 to 32,767
32,768 to 32,767

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dataview.getInt16(byteOffset)
dataview.getInt16(byteOffset)
dataview.getInt16(byteOffset)

Parameters:
byteoffset: It represents the offset (in byte) from the start of the data view.

Return:
An integer number of 16-bit.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
var dv = new ArrayBuffer(8);
var a = new DataView(dv);
a.setInt16(1,6578.9998);
document.write(a.getInt16(1));
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> var dv = new ArrayBuffer(8); var a = new DataView(dv); a.setInt16(1,6578.9998); document.write(a.getInt16(1)); </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
var dv = new ArrayBuffer(8);
var a = new DataView(dv);
a.setInt16(1,6578.9998);
document.write(a.getInt16(1));
</script>
</body>
</html>