diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/dataview/setbiguint64/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/dataview/setbiguint64/index.html | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/setbiguint64/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/setbiguint64/index.html new file mode 100644 index 0000000000..bd2bfef8f4 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/setbiguint64/index.html @@ -0,0 +1,83 @@ +--- +title: DataView.prototype.setBigUint64() +slug: Web/JavaScript/Reference/Global_Objects/DataView/setBigUint64 +tags: + - BigInt + - DataView + - setBigUint64 +translation_of: Web/JavaScript/Reference/Global_Objects/DataView/setBigUint64 +--- +<div>{{JSRef}}</div> + +<p><strong><code>setBigUint64()</code> </strong>方法在距DataView 的起始位置的指定字节偏移处存储一个无符号的64位整数(unsigned long long类型)值。</p> + +<div>{{EmbedInteractiveExample("pages/js/dataview-setbiguint64.html")}}</div> + + + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><var>dataview</var>.setBigUint64(byteOffset, value [, littleEndian])</pre> + +<h3 id="参数说明">参数说明</h3> + +<dl> + <dt>byteOffset</dt> + <dd>字节偏移量,为从视图的起始位置到数据存储位置的字节字节偏移量。</dd> + <dt>value</dt> + <dd>作为一个BigInt类型设置的数值。满足一个无符号的64位整数的最大可能数值是 <code><span class="blob-code-inner blob-code-marker">2n ** 64n - 1n</span></code><span class="blob-code-inner blob-code-marker"> (</span><code>18446744073709551615n</code><span class="blob-code-inner blob-code-marker">)</span>。当发生溢出时,将会变成0。</dd> + <dt>littleEndian</dt> + <dd>为可选参数,表示这个64位整数是否以little-endian 或者big-endian格式存储。如果设置为false 或者未指定(undefined),将会写入一个big-endian(大端模式:高位字节排放在内存的低地址端,低位字节排放在内存的高地址端)格式的数值。</dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p>{{jsxref("undefined")}}.</p> + +<h3 id="抛出的错误">抛出的错误</h3> + +<dl> + <dt>{{jsxref("RangeError")}}</dt> + <dd>如果 byteOffset设置导致存储该数值时超出了视图的末尾位置,将会抛出错误。</dd> +</dl> + +<h2 id="例子">例子</h2> + +<h3 id="使用_setBigUint64_方法">使用 <code>setBigUint64</code> 方法</h3> + +<pre class="brush:js">var buffer = new ArrayBuffer(8); +var dataview = new DataView(buffer); +dataview.setBigUint64(0, 3n); +dataview.getBigUint64(0); // 3n +</pre> + +<h2 id="相关规范">相关规范 </h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">解释</th> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-dataview.prototype.setbiguint64', 'DataView.prototype.setBigUint64()')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("javascript.builtins.DataView.setBigUint64")}}</p> + +<h2 id="请参阅">请参阅</h2> + +<ul> + <li>{{jsxref("DataView")}}</li> + <li>{{jsxref("ArrayBuffer")}}</li> + <li>{{jsxref("BigInt")}}</li> +</ul> |