Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

DataView.prototype.setBigInt64()

BaselineWidely available

setBigInt64() メソッドは、符号つき 64 ビット整数 (long long) をDataView の先頭からのバイト単位の指定されたオフセット位置に格納します。

試してみましょう

// Create an ArrayBuffer with a size in bytesconst buffer = new ArrayBuffer(16);// Highest possible BigInt value that fits in a signed 64-bit integerconst max = 2n ** (64n - 1n) - 1n;const view = new DataView(buffer);view.setBigInt64(1, max);console.log(view.getBigInt64(1));// Expected output: 9223372036854775807n

構文

js
setBigInt64(byteOffset, value);setBigInt64(byteOffset, value, littleEndian);

引数

byteOffset

データを格納するビューの先頭からのバイト単位のオフセットです。

value

BigInt として設定する値です。符号つき 64 ビット整数に符合する最も大きな値は、2n ** (64n -1n) - 1n (9223372036854775807n) です。これを上回ると、負の数 (-9223372036854775808n) になります。

littleEndian

省略可 64 ビット整数をリトルエンディアンまたはビッグエンディアンのどちらの形式で格納するかを示します。false またはundefined の場合、ビッグエンディアンの値が書き込まれます。

返値

undefined です。

発生するエラー

RangeError

byteOffset がビューの末尾を超えて格納するような値に設定されたときに発生します。

setBigInt64 メソッドの使用

js
var buffer = new ArrayBuffer(8);var dataview = new DataView(buffer);dataview.setBigInt64(0, 3n);dataview.getBigInt64(0); // 3n

仕様書

Specification
ECMAScript® 2026 Language Specification
# sec-dataview.prototype.setbigint64

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp