Note: The Float64x2 type is currently not part of the SIMD specification draft.
The SIMD.Float64x2
data type is a 128-bit vector divided into 2 lanes storing double precision floating point values.
Figure 1: SIMD.Float64x2 in a 128-bit SIMD register.
Syntax
SIMD.Float64x2(x, y);
Parameters
x
{{optional_inline}}- A double specifying the value of the first lane. Defaults to {{jsxref("NaN")}}.
y
{{optional_inline}}- A double specifying the value of the second lane. Defaults to {{jsxref("NaN")}}.
Constructor functions
In addition to the simple creator functions, the SIMD API provides the following constructor functions:
- {{jsxref("SIMD.splat", "SIMD.Float64x2.splat()")}}
- Creates a Float64x2 with all lanes set to a given value.
Note that you can also convert from another SIMD data type to Float64x2.
Note: SIMD types don't work with new
, as SIMD values are no "boxed" objects (comparable to String(s)
vs. new String(s)
, which creates a String object).
var v = new SIMD.Float64x2(1,2); // TypeError: SIMD.Float64x2 is not a constructor var w = new SIMD.Float64x2.splat(3); // TypeError: SIMD.Float64x2.splat is not a constructor
Instead, you just write:
var v = SIMD.Float64x2(1,2); var w = SIMD.Float64x2.splat(3);
Operations
To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.
Checking SIMD types
- {{jsxref("SIMD.check", "SIMD.Float64x2.check()")}}
- Returns a new Float64x2 if the parameter is a valid Float64x2 data type. Throws a {{jsxref("TypeError")}} otherwise.
Accessing and mutating lanes
- {{jsxref("SIMD.extractLane", "SIMD.Float64x2.extractLane()")}}
- Returns the value of the given lane.
- {{jsxref("SIMD.replaceLane", "SIMD.Float64x2.replaceLane()")}}
- Returns a new Float64x2 with the given lane value replaced.
Loading from and storing into typed arrays
- {{jsxref("SIMD.load", "SIMD.Float64x2.load()")}}
- {{jsxref("SIMD.load", "SIMD.Float64x2.load1()")}}
- Returns a new Float64x2 with the lane values loaded from a typed array.
- {{jsxref("SIMD.store", "SIMD.Float64x2.store()")}}
{{jsxref("SIMD.store", "SIMD.Float64x2.store1()")}} - Stores a Float64x2 into a typed array.
Arithmetic operations
- {{jsxref("SIMD.abs", "SIMD.Float64x2.abs()")}}
- Returns a new Float64x2 with the absolute lane values.
- {{jsxref("SIMD.add", "SIMD.Float64x2.add()")}}
- Returns a new Float64x2 with the lane values added (
a + b
). - {{jsxref("SIMD.div", "SIMD.Float64x2.div()")}}
- Returns a new Float64x2 with the lane values divided (
a / b
). - {{jsxref("SIMD.mul", "SIMD.Float64x2.mul()")}}
- Returns a new loat64x2 with the lane values multiplied (
a * b
). - {{jsxref("SIMD.neg", "SIMD.Float64x2.neg()")}}
- Returns a new Float64x2 with the negated lane values.
- {{jsxref("SIMD.reciprocalApproximation", "SIMD.Float64x2.reciprocalApproximation()")}}
- Returns a new Float64x2 with an approximation of the reciprocal lane values.
- {{jsxref("SIMD.reciprocalSqrtApproximation", "SIMD.Float64x2.reciprocalSqrtApproximation()")}}
- Returns a new Float64x2 with an approximation of the reciprocal square root lane values.
- {{jsxref("SIMD.sub", "SIMD.Float64x2.sub()")}}
- Returns a new Float64x2 with the lane values subtracted (
a - b
). - {{jsxref("SIMD.sqrt", "SIMD.Float64x2.sqrt()")}}
- Returns a new Float64x2 with the square root of the lane values.
Shuffling and swizzling
- {{jsxref("SIMD.shuffle", "SIMD.Float64x2.shuffle()")}}
- Returns a new Float64x2 with the lane values shuffled.
- {{jsxref("SIMD.swizzle", "SIMD.Float64x2.swizzle()")}}
- Returns a new Float64x2 with the lane values swizzled.
Min and max values
- {{jsxref("SIMD.max", "SIMD.Float64x2.max()")}}
- Returns a new Float64x2 with the maximum of the lane values.
- {{jsxref("SIMD.maxNum", "SIMD.Float64x2.maxNum()")}}
- Returns a new Float64x2 with the maximum of the lane values, preferring numbers over {{jsxref("NaN")}}.
- {{jsxref("SIMD.min", "SIMD.Float64x2.min()")}}
- Returns a new Float64x2 with the minimum of the lane values.
- {{jsxref("SIMD.minNum", "SIMD.Float64x2.minNum()")}}
- Returns a new Float64x2 with the minimum of the lane values, preferring numbers over {{jsxref("NaN")}}.
Selections
- {{jsxref("SIMD.select", "SIMD.Float64x2.select()")}}
- Returns a new loat64x2 with the lane values being a mix of the lanes depending on the selector mask.
Comparisons
- {{jsxref("SIMD.equal", "SIMD.Float64x2.equal()")}}
- Returns a selection mask depending on
a == b
. - {{jsxref("SIMD.notEqual", "SIMD.Float64x2.notEqual()")}}
- Returns a selection mask depending on
a != b
. - {{jsxref("SIMD.lessThan", "SIMD.Float64x2.lessThan()")}}
- Returns a selection mask depending on
a < b
. - {{jsxref("SIMD.lessThanOrEqual", "SIMD.Float64x2.lessThanOrEqual()")}}
- Returns a selection mask depending on
a <= b
. - {{jsxref("SIMD.greaterThan", "SIMD.Float64x2.greaterThan()")}}
- Returns a selection mask depending on
a > b
. - {{jsxref("SIMD.greaterThanOrEqual", "SIMD.Float64x2.greaterThanOrEqual()")}}
- Returns a selection mask depending on
a >= b
.
Data conversions
- {{jsxref("SIMD.fromFloat32x4Bits", "SIMD.Float64x2.fromFloat32x4Bits()")}}
- Creates a new Float64x2 data type with a bit-wise copy from a Float32x4.
- {{jsxref("SIMD.fromInt32x4Bits", "SIMD.Float64x2.fromInt32x4Bits()")}}
- Creates a new Float64x2 data type with a bit-wise copy from an Int32x4.
- {{jsxref("SIMD.fromInt16x8Bits", "SIMD.Float64x2.fromInt16x8Bits()")}}
- Creates a new Float64x2 data type with a bit-wise copy from an Int16x8.
- {{jsxref("SIMD.fromInt8x16Bits", "SIMD.Float64x2.fromInt8x16Bits()")}}
- Creates a new Float64x2 data type with a bit-wise copy from an Int8x16.
- {{jsxref("SIMD.fromUint32x4Bits", "SIMD.Float64x2.fromUint32x4Bits()")}}
- Creates a new Float64x2 data type with a bit-wise copy from a Uint32x4.
- {{jsxref("SIMD.fromUint16x8Bits", "SIMD.Float64x2.fromUint16x8Bits()")}}
- Creates a new Float64x2 data type with a bit-wise copy from a Uint16x8.
- {{jsxref("SIMD.fromUint8x16Bits", "SIMD.Float64x2.fromUint8x16Bits()")}}
- Creates a new Float64x2 data type with a bit-wise copy from a Uint8x16.
SIMD prototype
The following methods and properties are installed on the SIMD.Float64x2.prototype
.
SIMD.Float64x2.prototype.constructor
- Specifies the function that creates a SIMD object's prototype.
- {{jsxref("SIMD.toLocaleString", "SIMD.Float64x2.prototype.toLocaleString()")}}
- Returns a localized string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.
- {{jsxref("SIMD.toString", "SIMD.Float64x2.prototype.toString()")}}
- Returns a string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toString()")}} method.
- {{jsxref("SIMD.valueOf", "SIMD.Float64x2.prototype.valueOf()")}}
- Returns the primitive value of a SIMD object.
- {{jsxref("SIMD.toSource", "SIMD.Float64x2.prototype.toSource()")}} {{non-standard_inline}}
- Returns a string representing the source code of the object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.
Examples
Constructing a Float64x2
SIMD.Float64x2(1, 2); // Float64x2[1, 2] SIMD.Float64x2(1); // Float64x2[1, NaN] SIMD.Float64x2(); // Float64x2[NaN, NaN]
Specifications
{{WhyNoSpecStart}} The Float64x2 type is currently not part of the SIMD specification draft. {{WhyNoSpecEnd}}
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNightly("firefox")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNo}} | {{CompatNightly("firefox")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
See also
- {{jsxref("SIMD")}}