--- title: DataView.prototype.setFloat64() slug: Web/JavaScript/Reference/Global_Objects/DataView/setFloat64 translation_of: Web/JavaScript/Reference/Global_Objects/DataView/setFloat64 ---
{{JSRef}}

setFloat64()DataView起始位置以byte为计数的指定偏移量(byteOffset)处储存一个64-bit数(双精度浮点型).

{{EmbedInteractiveExample("pages/js/dataview-setfloat64.html")}}

语法

dataview.setFloat64(byteOffset, value [, littleEndian])

参数

byteOffset
偏移量,从头开始计算,单位为字节.
value
设置的数值.
littleEndian
{{optional_inline}} Indicates whether the 64-bit float is stored in {{Glossary("Endianness", "little- or big-endian")}} format. If false or undefined, a big-endian value is written.

返回

{{jsxref("undefined")}}.

抛出错误

{{jsxref("RangeError")}}
如果byteOffset超出了视图能储存的值,就会抛出错误.

例子

var buffer = new ArrayBuffer(8);
var dataview = new DataView(buffer);
dataview.setFloat64(0, 3);
dataview.getFloat64(0); // 3

规范

Specification Status Comment
{{SpecName('Typed Array')}} {{Spec2('Typed Array')}} Superseded by ECMAScript 6.
{{SpecName('ES6', '#sec-dataview.prototype.setfloat64', 'DataView.prototype.setFloat64')}} {{Spec2('ES6')}} Initial definition in an ECMA standard.
{{SpecName('ESDraft', '#sec-dataview.prototype.setfloat64', 'DataView.prototype.setFloat64')}} {{Spec2('ESDraft')}}  

浏览器支持

{{Compat("javascript.builtins.DataView.setFloat64")}}

相关内容