setBigInt64()
方法在距DataView
的起始位置的指定字节偏移处存储一个带符号的64位整数(long long类型)值。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
语法
dataview.setBigInt64(byteOffset, value [, littleEndian])
参数说明
- byteOffset
- 字节偏移量,为从视图的起始位置到数据存储位置的字节字节偏移量。
- value
- 作为一个
BigInt
类型设置的数值。满足一个带符号的64位整数的最大可能数值是2n ** (64n -1n) - 1n
(9223372036854775807n
)。当发生溢出时,将会变成负数(-9223372036854775808n
)。 - littleEndian
- 可选 为可选参数,表示这个64位整数是否以little-endian 或者big-endian格式存储。如果设置为
false
或者未指定(undefined
),将会写入一个big-endian(大端模式:高位字节排放在内存的低地址端,低位字节排放在内存的高地址端)格式的数值。
返回值
抛出的错误
RangeError
- 如果
byteOffset
设置导致存储该数值时超出了视图的末尾位置,将会抛出错误。
例子
使用 setBigInt64
方法
var buffer = new ArrayBuffer(8);
var dataview = new DataView(buffer);
dataview.setBigInt64(0, 3n);
dataview.getBigInt64(0); // 3n
相关规范
规范 | 状态 | 解释 |
---|---|---|
ECMAScript (ECMA-262) DataView.prototype.setBigInt64() |
Living Standard |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.