Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 987755 of SIMD.Bool32x4

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Bool32x4
  • Revision title: SIMD.Bool32x4
  • Revision id: 987755
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment

Revision Content

{{JSRef}} {{es7}}

The SIMD.Bool32x4 data type is a 128-bit vector divided into 4 lanes storing boolean values.

Syntax

SIMD.Bool32x4(x, y, z, w);

Parameters

x {{optional_inline}}
A boolean specifying the value of the first lane. Defaults to false.
y {{optional_inline}}
A boolean specifying the value of the second lane. Defaults to false.
z {{optional_inline}}
A boolean specifying the value of the third lane. Defaults to false.
w {{optional_inline}}
A boolean specifying the value of the fourth lane. Defaults to false.

Constructor functions

In addition to the simple creator function, the SIMD API provides the following constructor functions.

{{jsxref("SIMD.splat", "SIMD.Bool32x4.splat()")}}
Creates an Bool32x4 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.Bool32x4(true,false,true,false); 
// TypeError: SIMD.Bool32x4 is not a constructor
var w = new SIMD.Bool32x4.splat(true); 
// TypeError: SIMD.Bool32x4.splat is not a constructor

Instead, you just write:

var v = SIMD.Bool32x4(true, false, true, false);
var w = SIMD.Bool32x4.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.Bool32x4.check()")}}
Returns a new Bool32x4 if the parameter is a valid Bool32x4 data type. Throws a {{jsxref("TypeError")}} otherwise.

Accessing and mutating lanes

{{jsxref("SIMD.extractLane", "SIMD.Bool32x4.extractLane()")}}
Returns the value of the given lane.
{{jsxref("SIMD.replaceLane", "SIMD.Bool32x4.replaceLane()")}}
Returns a new Bool16x8 with the given lane value replaced.

Boolean operations

{{jsxref("SIMD.allTrue", "SIMD.Bool32x4.allTrue()")}}
Checks if all lanes hold a true value.
{{jsxref("SIMD.anyTrue", "SIMD.Bool32x4.anyTrue()")}}
Checks if any of the lanes hold a true value.

Bitwise logical operations

{{jsxref("SIMD.and", "SIMD.Bool32x4.and()")}}
Returns a new Bool32x4 with the logical AND of the lane values (a & b).
{{jsxref("SIMD.or", "SIMD.Bool32x4.or()")}}
Returns a new Bool32x4 with the logical OR of the lane values (a | b).
{{jsxref("SIMD.xor", "SIMD.Bool32x4.xor()")}}
Returns a new Bool32x4 with the logical XOR of the lane values (a ^ b).
{{jsxref("SIMD.not", "SIMD.Bool32x4.not()")}}
Returns a new Bool32x4 with lane with the logical NOT of the lane values (~a).

SIMD prototype

The following methods and properties are installed on the SIMD.Bool32x4.prototype.

SIMD.Bool32x4.prototype.constructor
Specifies the function that creates a SIMD object's prototype.
{{jsxref("SIMD.toLocaleString", "SIMD.Bool32x4.prototype.toLocaleString()")}}
Returns a localized string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.
{{jsxref("SIMD.toString", "SIMD.Bool32x4.prototype.toString()")}}
Returns a string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toString()")}} method.
{{jsxref("SIMD.valueOf", "SIMD.Bool32x4.prototype.valueOf()")}}
Returns the primitive value of a SIMD object.
{{jsxref("SIMD.toSource", "SIMD.Bool32x4.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 Bool32x4

SIMD.Bool32x4(true, false, true, false); // Bool32x4[true,false,true,false]
SIMD.Bool32x4(true, false);              // Bool32x4[true,false,false,false]
SIMD.Bool32x4();                         // Bool32x4[false,false,false,false]

Specifications

Specification Status Comment
{{SpecName('SIMD', '#bool32x4', 'Bool32x4')}} {{Spec2('SIMD')}} Initial definition.

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")}}

Revision Source

<div>{{JSRef}} {{es7}}</div>

<p>The <strong><code>SIMD.Bool32x4</code></strong> data type is a 128-bit vector divided into 4 lanes storing boolean values.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
SIMD.Bool32x4(x, y, z, w);</pre>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt><code>x</code> {{optional_inline}}</dt>
 <dd>A boolean specifying the value of the first lane. Defaults to <code>false</code>.</dd>
 <dt><code>y</code> {{optional_inline}}</dt>
 <dd>A boolean specifying the value of the second lane. Defaults to <code>false</code>.</dd>
 <dt><code>z</code> {{optional_inline}}</dt>
 <dd>A boolean specifying the value of the third lane. Defaults to <code>false</code>.</dd>
 <dt><code>w</code> {{optional_inline}}</dt>
 <dd>A boolean specifying the value of the fourth lane. Defaults to <code>false</code>.</dd>
</dl>

<h2 id="Constructor_functions">Constructor functions</h2>

<p>In addition to the simple creator function, the SIMD API provides the following constructor functions.</p>

<dl>
 <dt>{{jsxref("SIMD.splat", "SIMD.Bool32x4.splat()")}}</dt>
 <dd>Creates an Bool32x4 with all lanes set to a given value.</dd>
</dl>

<div class="note">
<p><strong>Note:</strong> SIMD types don't work with <code>new</code>, as SIMD values are no "boxed" objects (comparable to <code>String(s)</code> vs. <code>new String(s)</code>, which creates a String object).</p>

<pre class="brush: js example-bad">
var v = new SIMD.Bool32x4(true,false,true,false); 
// TypeError: SIMD.Bool32x4 is not a constructor
var w = new SIMD.Bool32x4.splat(true); 
// TypeError: SIMD.Bool32x4.splat is not a constructor</pre>

<p>Instead, you just write:</p>

<pre class="brush: js example-good">
var v = SIMD.Bool32x4(true, false, true, false);
var w = SIMD.Bool32x4.splat(true);</pre>
</div>

<h2 id="Operations">Operations</h2>

<p>To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.</p>

<h3 id="Checking_SIMD_types">Checking SIMD types</h3>

<dl>
 <dt>{{jsxref("SIMD.check", "SIMD.Bool32x4.check()")}}</dt>
 <dd>Returns a new Bool32x4 if the parameter is a valid Bool32x4 data type. Throws a {{jsxref("TypeError")}} otherwise.</dd>
</dl>

<h3 id="Accessing_and_mutating_lanes">Accessing and mutating lanes</h3>

<dl>
 <dt>{{jsxref("SIMD.extractLane", "SIMD.Bool32x4.extractLane()")}}</dt>
 <dd>Returns the value of the given lane.</dd>
 <dt>{{jsxref("SIMD.replaceLane", "SIMD.Bool32x4.replaceLane()")}}</dt>
 <dd>Returns a new Bool16x8 with the given lane value replaced.</dd>
</dl>

<dl>
 <dt>
 <h3 id="Boolean_operations">Boolean operations</h3>
 </dt>
 <dt>{{jsxref("SIMD.allTrue", "SIMD.Bool32x4.allTrue()")}}</dt>
 <dd>Checks if all lanes hold a <code>true</code> value.</dd>
 <dt>{{jsxref("SIMD.anyTrue", "SIMD.Bool32x4.anyTrue()")}}</dt>
 <dd>Checks if any of the lanes hold a <code>true</code> value.</dd>
</dl>

<h3 id="Bitwise_logical_operations">Bitwise logical operations</h3>

<dl>
 <dt>{{jsxref("SIMD.and", "SIMD.Bool32x4.and()")}}</dt>
 <dd>Returns a new Bool32x4 with the logical AND of the lane values (<code>a &amp; b</code>).</dd>
 <dt>{{jsxref("SIMD.or", "SIMD.Bool32x4.or()")}}</dt>
 <dd>Returns a new Bool32x4 with the logical OR of the lane values (<code>a | b</code>).</dd>
 <dt>{{jsxref("SIMD.xor", "SIMD.Bool32x4.xor()")}}</dt>
 <dd>Returns a new Bool32x4 with the logical XOR of the lane values (<code>a ^ b</code>).</dd>
 <dt>{{jsxref("SIMD.not", "SIMD.Bool32x4.not()")}}</dt>
 <dd>Returns a new Bool32x4 with lane with the logical NOT of the lane values (<code>~a</code>).</dd>
</dl>

<h2 id="SIMD_prototype">SIMD prototype</h2>

<p>The following methods and properties are installed on the <code>SIMD.Bool32x4.prototype</code>.</p>

<dl>
 <dt><code>SIMD.Bool32x4.prototype.constructor</code></dt>
 <dd>Specifies the function that creates a SIMD object's prototype.</dd>
 <dt>{{jsxref("SIMD.toLocaleString", "SIMD.Bool32x4.prototype.toLocaleString()")}}</dt>
 <dd>Returns a localized string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.</dd>
 <dt>{{jsxref("SIMD.toString", "SIMD.Bool32x4.prototype.toString()")}}</dt>
 <dd>Returns a string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toString()")}} method.</dd>
 <dt>{{jsxref("SIMD.valueOf", "SIMD.Bool32x4.prototype.valueOf()")}}</dt>
 <dd>Returns the primitive value of a SIMD object.</dd>
 <dt>{{jsxref("SIMD.toSource", "SIMD.Bool32x4.prototype.toSource()")}} {{non-standard_inline}}</dt>
 <dd>Returns a string representing the source code of the object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<h3 id="Constructing_a_Bool32x4">Constructing a Bool32x4</h3>

<pre class="brush: js">
SIMD.Bool32x4(true, false, true, false); // Bool32x4[true,false,true,false]
SIMD.Bool32x4(true, false);              // Bool32x4[true,false,false,false]
SIMD.Bool32x4();                         // Bool32x4[false,false,false,false]
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('SIMD', '#bool32x4', 'Bool32x4')}}</td>
   <td>{{Spec2('SIMD')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNightly("firefox")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNightly("firefox")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{jsxref("SIMD")}}</li>
</ul>
Revert to this revision