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 1017105 of SIMD.Uint16x8

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Uint16x8
  • Revision title: SIMD.Uint16x8
  • Revision id: 1017105
  • Created:
  • Creator: fscholz
  • Is current revision? Yes
  • Comment Bug 1201934 - Remove SIMD shiftRightArithmeticByScalar and shiftRightLogicalByScalar

Revision Content

{{JSRef}} {{SeeCompatTable}}

The SIMD.Uint16x8 data type is a 128-bit vector divided into 8 lanes storing 16-bit unsigned integer values.

Syntax

SIMD.Uint16x8(s0, s1, s2, s3, s4, s5, s6, s7);

Parameters

s[0-7] {{optional_inline}}
An integer specifying the value of the lane. Defaults to 0.

Constructor functions

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

{{jsxref("SIMD.splat", "SIMD.Uint16x8.splat()")}}
Creates a Uint16x8 with all lanes set to a given value.

You can also convert from another SIMD data type to Uint16x8.

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.Uint16x8(1,2,3,4,5,6,7,8); 
// TypeError: SIMD.Uint16x8 is not a constructor
var w = new SIMD.Uint16x8.splat(3); 
// TypeError: SIMD.Uint16x8.splat is not a constructor

Instead, you just write:

var v = SIMD.Uint16x8(1,2,3,4,5,6,7,8);
var w = SIMD.Uint16x8.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.Uint16x8.check()")}}
Returns a new Uint16x8 if the parameter is a valid Int16x8 data type. Throws a {{jsxref("TypeError")}} otherwise.

Accessing and mutating lanes

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

Loading from and storing into typed arrays

{{jsxref("SIMD.load", "SIMD.Uint16x8.load()")}}
Returns a new Uint16x8 with the lane values loaded from a typed array.
{{jsxref("SIMD.store", "SIMD.Uint16x8.store()")}}
Stores an Uint16x8 into a typed array.

Arithmetic operations

{{jsxref("SIMD.add", "SIMD.Uint16x8.add()")}}
Returns a new Uint16x8 with the lane values added (a + b).
{{jsxref("SIMD.addSaturate", "SIMD.Uint16x8.addSaturate()")}}
Returns a new Uint16x8 with the lane values added (a + b) and saturating behavior on overflow.
{{jsxref("SIMD.mul", "SIMD.Uint16x8.mul()")}}
Returns a new Uint16x8 with the lane values multiplied (a * b).
{{jsxref("SIMD.neg", "SIMD.Uint16x8.neg()")}}
Returns a new Uint16x8 with the negated lane values.
{{jsxref("SIMD.sub", "SIMD.Uint16x8.sub()")}}
Returns a new Uint16x8 with the lane values subtracted (a - b).
{{jsxref("SIMD.subSaturate", "SIMD.Uint16x8.subSaturate()")}}
Returns a new Uint16x8 with the lane values subtracted (a - b) and saturating behavior on overflow.

Shuffling and swizzling

{{jsxref("SIMD.shuffle", "SIMD.Uint16x8.shuffle()")}}
Returns a new Uint16x8 with the lane values shuffled.
{{jsxref("SIMD.swizzle", "SIMD.Uint16x8.swizzle()")}}
Returns a new Uint16x8 with the lane values swizzled.

Selections

{{jsxref("SIMD.select", "SIMD.Uint16x8.select()")}}
Returns a new Uint16x8 with the lane values being a mix of the lanes depending on the selector mask.

Comparisons

{{jsxref("SIMD.equal", "SIMD.Uint16x8.equal()")}}
Returns a selection mask depending on a == b.
{{jsxref("SIMD.notEqual", "SIMD.Uint16x8.notEqual()")}}
Returns a selection mask depending on a != b.
{{jsxref("SIMD.lessThan", "SIMD.Uint16x8.lessThan()")}}
Returns a selection mask depending on a < b.
{{jsxref("SIMD.lessThanOrEqual", "SIMD.Uint16x8.lessThanOrEqual()")}}
Returns a selection mask depending on a <= b.
{{jsxref("SIMD.greaterThan", "SIMD.Uint16x8.greaterThan()")}}
Returns a selection mask depending on a > b.
{{jsxref("SIMD.greaterThanOrEqual", "SIMD.Uint16x8.greaterThanOrEqual()")}}
Returns a selection mask depending on a >= b.

Bitwise logical operations

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

Bitwise shift operations

{{jsxref("SIMD.shiftLeftByScalar", "SIMD.Uint16x8.shiftLeftByScalar()")}}
Returns a new Uint16x8 with the lane values shifted left by a given bit count (a << bits).
{{jsxref("SIMD.shiftRightByScalar", "SIMD.Uint16x8.shiftRightByScalar()")}}
Returns a new Uint16x8 with the lane values shifted right.

Data conversions

{{jsxref("SIMD.fromFloat32x4Bits", "SIMD.Uint16x8.fromFloat32x4Bits()")}}
Creates a new Uint16x8 data type with a bit-wise copy from a Float32x4.
{{jsxref("SIMD.fromFloat64x2Bits", "SIMD.Uint16x8.fromFloat64x2Bits()")}}
Creates a new Uint16x8 data type with a bit-wise copy from a Float64x2.
{{jsxref("SIMD.fromInt32x4Bits", "SIMD.Uint16x8.fromInt32x4Bits()")}}
Creates a new Uint16x8 data type with a bit-wise copy from an Int32x4.
{{jsxref("SIMD.fromInt16x8Bits", "SIMD.Uint16x8.fromInt16x8Bits()")}}
Creates a new Uint16x8 data type with a bit-wise copy from an Int16x8.
{{jsxref("SIMD.fromInt8x16Bits", "SIMD.Uint16x8.fromInt8x16Bits()")}}
Creates a new Uint16x8 data type with a bit-wise copy from an Int8x16.
{{jsxref("SIMD.fromUint32x4Bits", "SIMD.Uint16x8.fromUint32x4Bits()")}}
Creates a new Uint16x8 data type with a bit-wise copy from a Uint32x4.
{{jsxref("SIMD.fromUint8x16Bits", "SIMD.Uint16x8.fromUint8x16Bits()")}}
Creates a new Uint16x8 data type with a bit-wise copy from a Uint8x16.

SIMD prototype

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

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

SIMD.Uint16x8(1, 2, 3, 4, 5, 6, 7, 8); // Int16x8[1,2,3,4,5,6,7,8]
SIMD.Uint16x8(1, 2);                   // Int16x8[1,2,0,0,0,0,0,0]
SIMD.Uint16x8();                       // Int16x8[0,0,0,0,0,0,0,0]

Specifications

Specification Status Comment
{{SpecName('SIMD', '#uint16x8', 'Uint16x8')}} {{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}} {{SeeCompatTable}}</div>

<p>The <strong><code>SIMD.Uint16x8</code></strong> data type is a 128-bit vector divided into 8 lanes storing 16-bit unsigned integer values.</p>

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

<pre class="syntaxbox">
SIMD.Uint16x8(s0, s1, s2, s3, s4, s5, s6, s7);</pre>

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

<dl>
 <dt><code>s[0-7]</code> {{optional_inline}}</dt>
 <dd>An integer specifying the value of the lane. Defaults to 0.</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.Uint16x8.splat()")}}</dt>
 <dd>Creates a Uint16x8 with all lanes set to a given value.</dd>
</dl>

<p>You can also <a href="#Data_conversions">convert from another SIMD data type to Uint16x8</a>.</p>

<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.Uint16x8(1,2,3,4,5,6,7,8); 
// TypeError: SIMD.Uint16x8 is not a constructor
var w = new SIMD.Uint16x8.splat(3); 
// TypeError: SIMD.Uint16x8.splat is not a constructor
</pre>

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

<pre class="brush: js example-good">
var v = SIMD.Uint16x8(1,2,3,4,5,6,7,8);
var w = SIMD.Uint16x8.splat(3);
</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.Uint16x8.check()")}}</dt>
 <dd>Returns a new Uint16x8 if the parameter is a valid Int16x8 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.Uint16x8.extractLane()")}}</dt>
 <dd>Returns the value of the given lane.</dd>
 <dt>{{jsxref("SIMD.replaceLane", "SIMD.Uint16x8.replaceLane()")}}</dt>
 <dd>Returns a new Uint16x8 with the given lane value replaced.</dd>
</dl>

<h3 id="Loading_from_and_storing_into_typed_arrays">Loading from and storing into typed arrays</h3>

<dl>
 <dt>{{jsxref("SIMD.load", "SIMD.Uint16x8.load()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values loaded from a <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>.</dd>
 <dt>{{jsxref("SIMD.store", "SIMD.Uint16x8.store()")}}</dt>
 <dd>Stores an Uint16x8 into a <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>.</dd>
</dl>

<h3 id="Arithmetic_operations">Arithmetic operations</h3>

<dl>
 <dt>{{jsxref("SIMD.add", "SIMD.Uint16x8.add()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values added (<code>a + b</code>).</dd>
 <dt>{{jsxref("SIMD.addSaturate", "SIMD.Uint16x8.addSaturate()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values added (<code>a + b</code>) and saturating behavior on overflow.</dd>
 <dt>{{jsxref("SIMD.mul", "SIMD.Uint16x8.mul()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values multiplied (<code>a * b</code>).</dd>
 <dt>{{jsxref("SIMD.neg", "SIMD.Uint16x8.neg()")}}</dt>
 <dd>Returns a new Uint16x8 with the negated lane values.</dd>
 <dt>{{jsxref("SIMD.sub", "SIMD.Uint16x8.sub()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values subtracted (<code>a - b</code>).</dd>
 <dt>{{jsxref("SIMD.subSaturate", "SIMD.Uint16x8.subSaturate()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values subtracted (<code>a - b</code>) and&nbsp;saturating behavior on overflow.</dd>
 <dt>
 <h3 id="Shuffling_and_swizzling">Shuffling and swizzling</h3>
 </dt>
 <dt>{{jsxref("SIMD.shuffle", "SIMD.Uint16x8.shuffle()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values shuffled.</dd>
 <dt>{{jsxref("SIMD.swizzle", "SIMD.Uint16x8.swizzle()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values swizzled.</dd>
</dl>

<h3 id="Selections">Selections</h3>

<dl>
 <dt>{{jsxref("SIMD.select", "SIMD.Uint16x8.select()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values being a mix of the lanes depending on the selector mask.</dd>
</dl>

<h3 id="Comparisons">Comparisons</h3>

<dl>
 <dt>{{jsxref("SIMD.equal", "SIMD.Uint16x8.equal()")}}</dt>
 <dd>Returns a selection mask depending on <code>a == b</code>.</dd>
 <dt>{{jsxref("SIMD.notEqual", "SIMD.Uint16x8.notEqual()")}}</dt>
 <dd>Returns a selection mask depending on <code>a != b</code>.</dd>
 <dt>{{jsxref("SIMD.lessThan", "SIMD.Uint16x8.lessThan()")}}</dt>
 <dd>Returns a selection mask depending on <code>a &lt; b</code>.</dd>
 <dt>{{jsxref("SIMD.lessThanOrEqual", "SIMD.Uint16x8.lessThanOrEqual()")}}</dt>
 <dd>Returns a selection mask depending on <code>a &lt;= b</code>.</dd>
 <dt>{{jsxref("SIMD.greaterThan", "SIMD.Uint16x8.greaterThan()")}}</dt>
 <dd>Returns a selection mask depending on <code>a &gt; b</code>.</dd>
 <dt>{{jsxref("SIMD.greaterThanOrEqual", "SIMD.Uint16x8.greaterThanOrEqual()")}}</dt>
 <dd>Returns a selection mask depending on <code>a &gt;= b</code>.</dd>
</dl>

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

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

<h3 id="Bitwise_shift_operations">Bitwise shift operations</h3>

<dl>
 <dt>{{jsxref("SIMD.shiftLeftByScalar", "SIMD.Uint16x8.shiftLeftByScalar()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values shifted left by a given bit count (<code>a &lt;&lt; bits</code>).</dd>
 <dt>{{jsxref("SIMD.shiftRightByScalar", "SIMD.Uint16x8.shiftRightByScalar()")}}</dt>
 <dd>Returns a new Uint16x8 with the lane values shifted right.</dd>
</dl>

<h3 id="Data_conversions">Data conversions</h3>

<dl>
 <dt>{{jsxref("SIMD.fromFloat32x4Bits", "SIMD.Uint16x8.fromFloat32x4Bits()")}}</dt>
 <dd>Creates a new Uint16x8 data type with a bit-wise copy from a Float32x4.</dd>
 <dt>{{jsxref("SIMD.fromFloat64x2Bits", "SIMD.Uint16x8.fromFloat64x2Bits()")}}</dt>
 <dd>Creates a new Uint16x8 data type with a bit-wise copy from a Float64x2.</dd>
 <dt>{{jsxref("SIMD.fromInt32x4Bits", "SIMD.Uint16x8.fromInt32x4Bits()")}}</dt>
 <dd>Creates a new Uint16x8 data type with a bit-wise copy from an Int32x4.</dd>
 <dt>{{jsxref("SIMD.fromInt16x8Bits", "SIMD.Uint16x8.fromInt16x8Bits()")}}</dt>
 <dd>Creates a new Uint16x8 data type with a bit-wise copy from an Int16x8.</dd>
 <dt>{{jsxref("SIMD.fromInt8x16Bits", "SIMD.Uint16x8.fromInt8x16Bits()")}}</dt>
 <dd>Creates a new Uint16x8 data type with a bit-wise copy from an Int8x16.</dd>
 <dt>{{jsxref("SIMD.fromUint32x4Bits", "SIMD.Uint16x8.fromUint32x4Bits()")}}</dt>
 <dd>Creates a new Uint16x8 data type with a bit-wise copy from a Uint32x4.</dd>
 <dt>{{jsxref("SIMD.fromUint8x16Bits", "SIMD.Uint16x8.fromUint8x16Bits()")}}</dt>
 <dd>Creates a new Uint16x8 data type with a bit-wise copy from a Uint8x16.</dd>
</dl>

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

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

<dl>
 <dt><code>SIMD.Uint16x8.prototype.constructor</code></dt>
 <dd>Specifies the function that creates a SIMD object's prototype.</dd>
 <dt>{{jsxref("SIMD.toLocaleString", "SIMD.Uint16x8.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.Uint16x8.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.Uint16x8.prototype.valueOf()")}}</dt>
 <dd>Returns the primitive value of a SIMD object.</dd>
 <dt>{{jsxref("SIMD.toSource", "SIMD.Uint16x8.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_Uint16x8">Constructing a Uint16x8</h3>

<pre class="brush: js">
SIMD.Uint16x8(1, 2, 3, 4, 5, 6, 7, 8); // Int16x8[1,2,3,4,5,6,7,8]
SIMD.Uint16x8(1, 2);                   // Int16x8[1,2,0,0,0,0,0,0]
SIMD.Uint16x8();                       // Int16x8[0,0,0,0,0,0,0,0]
</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', '#uint16x8', 'Uint16x8')}}</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