The Float64Array type represents an array of 64-bit floating point numbers (corresponding to the C double data type) in the platform byte order. If control over byte order is needed, use DataView instead.
Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).
Constructors
TypedArray represents any of the typed array object types.Float64Array Float64Array(unsigned long length); |
Float64Array Float64Array(TypedArray array); |
Float64Array Float64Array(sequence<type> array); |
Float64Array Float64Array(ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long length); |
Method overview
TypedArray represents any of the typed array object types.void set(TypedArray array, optional unsigned long offset); |
void set(type[] array, optional unsigned long offset); |
Float64Array subarray(long begin, optional long end); |
Attributes
| Attribute | Type | Description |
buffer |
ArrayBuffer |
The ArrayBuffer object used to contain the TypedArray datas. Read only. |
byteOffset |
unsigned long |
The index at wich starts the TypedArray in it underlying ArrayBuffer. Read only. |
length |
unsigned long |
The number of entries in the array. Read only. |
Constants
Element size
| Constant | Value | Description |
BYTES_PER_ELEMENT |
8 | The size, in bytes, of each array element. |
Constructor
Returns a new Float64Array object. Every entry in the array is initialized to 0 unless initial data is specifically provided.
Float64Array Float64Array( unsigned long length ); Float64Array Float64Array( TypedArray array ); Float64Array Float64Array( sequence<type> array ); Float64Array Float64Array( ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long length );
Parameters
-
length - The number of elements in the byte array. If unspecified, length of the array view will match the buffer's length.
-
array -
An object of any of the typed array types (such as Uint8
Array), or a sequence of objects of a particular type, to copy into a newArrayBuffer. Each value in the source array is converted to a 64-bit floating point number before being copied into the new array. -
buffer -
An existing
ArrayBufferto use as the storage for the newFloat64Arrayobject. -
byteOffset -
The offset, in bytes, to the first byte in the specified buffer for the new view to reference. If not specified, the
Float64Array's view of the buffer will start with the first byte.
Return value
A new Float64Array object representing the specified data buffer.
Notes
The first form of the constructor, accepting only a length, creates a new ArrayBuffer object that can hold the specified number of 64-bit floats, then creates and returns a typed array view referring to that new buffer. The length must be specified in this case.
The second form creates a new ArrayBuffer object that is a duplicate of the specified array, except with each element in the new array converted to a 64-bit float.
The third form of the constructor likewise creates a new ArrayBuffer object that is a duplicate of the specified JavaScript array, with each element in the new array converted to a 64-bit float.
The final form of the constructor creates a new Float64Array object, using the specified ArrayBuffer as its storage. This lets you access the existing buffer in a different format. If specified, the byteOffset and length parameters let you create the new view to only a portion of the buffer.
Exceptions thrown
-
INDEX_SIZE_ERR -
The specified
byteOffsetisn't a multiple of the element size, or thebyteOffsetandlengthresult in the specified view extending past the end of the buffer.
Methods
set()
Sets multiple values in the typed array, reading input values from a specified array.
void set( TypedArray array, optional unsigned long offset ); void set( type[] array, optional unsigned long offset );
Parameters
-
array -
An array from which to copy values. All values from the source array are copied into the target array, unless the length of the source array plus the offset exceeds the length of the target array, in which case an exception is thrown. If the source array is a typed array, the two arrays may share the same underlying
ArrayBuffer; the browser will intelligently copy the source range of the buffer to the destination range. - offset Optional
-
The offset into the target array at which to begin writing values from the source
array. If you omit this value, 0 is assumed (that is, the sourcearraywill overwrite values in the target array starting at index 0).
subarray()
Returns a new Float64Array view on the ArrayBuffer store for this Float64Array object.
Float64Array subarray( long begin, optional long end );
Parameters
-
begin -
The offset to the first element in the array to be referenced by the new
Float64Arrayobject. -
endOptional -
The offset to the first element beyond the array to be referenced by the new
Float64Arrayobject; if not specified, all elements from the one specified bybeginto the end of the array are included in the new view.
Notes
The range specified by begin and end is clamped to the valid index range for the current array; if the computed length of the new array would be negative, it's clamped to zero. If either begin or end is negative, it refers to an index from the end of the array instead of from the beginning.