aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/dataview/setbiguint64/index.html
blob: bd2bfef8f488e058c7f1b667e20e11fa4e07aaa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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>