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.

SIMD.%type%.addSaturate()

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The static SIMD.%type%.addSaturate() method returns a new instance with the lane values added (a + b) and saturating behavior on overflow.

Note: This operation is not defined on Uint32x4 and Int32x4, because it is not accelerated by current hardware on those types.

Syntax

SIMD.Int8x16.addSaturate(a, b)
SIMD.Int16x8.addSaturate(a, b)

SIMD.Uint8x16.addSaturate(a, b) 
SIMD.Uint16x8.addSaturate(a, b)

Parameters

a
An instance of a SIMD type.
b
Another instance of a SIMD type.

Return value

A new corresponding SIMD data type with the lane values of a and b added (a + b).

Examples

The following example demonstrates the saturating behavior for Uint16 (maximum value 65535) and Int16 (maximum value 32767). If the addition overflows, the lanes will have the maximum possible value.

var a = SIMD.Uint16x8(65533, 65534, 65535, 65535, 1, 1, 1, 1); 
var b = SIMD.Uint16x8(1, 1, 1, 5000, 1, 1, 1, 1); 
SIMD.Uint16x8.addSaturate(a, b); 
// Uint16x8[65534, 65535, 65535, 65535, 2, 2, 2, 2]

var c = SIMD.Int16x8(32765, 32766, 32767, 32767, 1, 1, 1, 1);
var d = SIMD.Int16x8(1, 1, 1, 5000, 1, 1, 1, 1);
SIMD.Int16x8.addSaturate(c, d);
// Int16x8[32766, 32767, 32767, 32767, 2, 2, 2, 2]

Specifications

Specification Status Comment
SIMD
The definition of 'SIMDConstructor.addSaturate' in that specification.
Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support Nightly build No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support Nightly build No support No support No support

See also

ドキュメントのタグと貢献者

 このページの貢献者: fscholz
 最終更新者: fscholz,