DataView.prototype.setBigUint64()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.
setBigUint64()
メソッドは、符号なし 64 ビット整数 (unsigned long long) を DataView
の先頭からのバイト単位の指定されたオフセット位置に格納します。
試してみましょう
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);
// Highest possible BigInt value that fits in an unsigned 64-bit integer
const max = 2n ** 64n - 1n;
const view = new DataView(buffer);
view.setBigUint64(1, max);
console.log(view.getBigUint64(1));
// Expected output: 18446744073709551615n
構文
setBigUint64(byteOffset, value);
setBigUint64(byteOffset, value, littleEndian);
引数
- byteOffset
-
データを格納するビューの先頭からのバイト単位のオフセットです。
- value
-
BigInt
として設定する値です。符号なし 64 ビット整数に符合する最も大きな値は、2n ** 64n - 1n
(18446744073709551615n
) です。これを上回ると、ゼロ (0n
) になります。 - littleEndian
-
省略可 64 ビット整数をリトルエンディアンまたはビッグエンディアンのどちらの形式で格納するかを示します。
false
またはundefined
の場合、ビッグエンディアンの値が書き込まれます。
返値
undefined
です。
発生するエラー
RangeError
-
byteOffset
がビューの末尾を超えて格納するような値に設定されたときに発生します。
例
setBigUint64
メソッドの使用
var buffer = new ArrayBuffer(8);
var dataview = new DataView(buffer);
dataview.setBigUint64(0, 3n);
dataview.getBigUint64(0); // 3n
仕様書
Specification |
---|
ECMAScript® 2025 Language Specification # sec-dataview.prototype.setbiguint64 |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setBigUint64 |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support