Note: The Bool64x2 type is currently not part of the SIMD specification draft.
The SIMD.Bool64x2
data type is a 128-bit vector divided into 2 lanes storing boolean values.
Syntax
SIMD.Bool64x2(x, y);
Parameters
x
{{optional_inline}}- A boolean specifying the value of the first lane. Defaults to
false
. y
{{optional_inline}}- An boolean specifying the value of the second lane. Defaults to
false
.
Constructor functions
In addition to the simple creator functions, the SIMD API provides the following constructor functions:
- {{jsxref("SIMD.splat", "SIMD.Bool64x2.splat()")}}
- Creates a Bool64x2 with all lanes set to a given value.
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.Bool64x2(true,false); // TypeError: SIMD.Bool64x2 is not a constructor var w = new SIMD.Bool64x2.splat(true); // TypeError: SIMD.Bool64x2.splat is not a constructor
Instead, you just write:
var v = SIMD.Bool64x2(true,false); var w = SIMD.Boolt64x2.splat(true);
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.Bool64x2.check()")}}
- Returns a new Bool64x2 if the parameter is a valid Bool64x2 data type. Throws a {{jsxref("TypeError")}} otherwise.
Accessing and mutating lanes
- {{jsxref("SIMD.extractLane", "SIMD.Bool64x2.extractLane()")}}
- Returns the value of the given lane.
- {{jsxref("SIMD.replaceLane", "SIMD.Bool64x2.replaceLane()")}}
- Returns a new Bool64x2 with the given lane value replaced.
Boolean operations
- {{jsxref("SIMD.allTrue", "SIMD.Bool64x2.allTrue()")}}
- Checks if all lanes hold a
true
value. - {{jsxref("SIMD.anyTrue", "SIMD.Bool64x2.anyTrue()")}}
- Checks if any of the lanes hold a
true
value.
Bitwise logical operations
- {{jsxref("SIMD.and", "SIMD.Bool64x2.and()")}}
- Returns a new Bool64x2 with the logical AND of the lane values (
a & b
). - {{jsxref("SIMD.or", "SIMD.Bool64x2.or()")}}
- Returns a new Bool64x2 with the logical OR of the lane values (
a | b
). - {{jsxref("SIMD.xor", "SIMD.Bool64x2.xor()")}}
- Returns a new Bool64x2 with the logical XOR of the lane values (
a ^ b
). - {{jsxref("SIMD.not", "SIMD.Bool64x2.not()")}}
- Returns a new Bool64x2 with the logical NOT of the lane values (
~a
).
SIMD prototype
The following methods and properties are installed on the SIMD.Bool64x2.prototype
.
SIMD.Bool64x2.prototype.constructor
- Specifies the function that creates a SIMD object's prototype.
- {{jsxref("SIMD.toLocaleString", "SIMD.Bool64x2.prototype.toLocaleString()")}}
- Returns a localized string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.
- {{jsxref("SIMD.toString", "SIMD.Bool64x2.prototype.toString()")}}
- Returns a string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toString()")}} method.
- {{jsxref("SIMD.valueOf", "SIMD.Bool64x2.prototype.valueOf()")}}
- Returns the primitive value of a SIMD object.
- {{jsxref("SIMD.toSource", "SIMD.Bool64x2.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 Bool64x2
SIMD.Bool64x2(true, false); // Bool64x2[true, false] SIMD.Bool64x2(1); // Bool64x2[true, false] SIMD.Bool64x2(); // Bool64x2[false, false]
Specifications
{{WhyNoSpecStart}} The Bool64x2 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")}}