JavaScript DataView.getInt16() 方法

2025年3月18日 | 2 分钟阅读

JavaScript DataView.getInt16() 是 DataView 中的一个内置方法。它用于获取指定位置的带符号 16 位整型(short)数字。

注意:16 位整数值的范围对于无符号整数是 0 到 65,535,对于带符号整数是 -32,768 到 32,767。

语法

参数

byteoffset:从视图开始处读取数据的字节偏移量。

返回值

此方法返回一个带符号的 16 位整数。

浏览器支持

Chrome9
Safari5.1
火狐15
Opera12.1

示例 1

输出

If we give a float value then output will be an Integer

3

示例 2

输出

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

0

示例 3

输出

PI value will be 

3

示例 4

输出

If we provide Integer value then output will be.

7