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%.subSaturate() method returns a new instance with the lane values subtracted (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.


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

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


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

Return value

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


The following example demonstrates the saturating behavior for Uint16 (maximum value 65535, minimum value 0) and Int16 (maximum value 32767, minimum value -32678). If the subtraction overflows, the lanes will have the minimum/maximum possible value.

var a = SIMD.Uint16x8(5, 1, 1, 1, 1, 1, 1, 1); 
var b = SIMD.Uint16x8(10, 1, 1, 1, 1, 1, 1, 1); 
SIMD.Uint16x8.subSaturate(a, b); 
// Uint16x8[0, 0, 0, 0, 0, 0, 0, 0]

var c = SIMD.Int16x8(-100, 0, 0, 0, 0, 0, 0, 0);
var d = SIMD.Int16x8(32767, 0, 0, 0, 0, 0, 0, 0);
SIMD.Int16x8.subSaturate(c, d);
// Int16x8[-32768, 0, 0, 0, 0, 0, 0, 0, 0]


Specification Status Comment
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

Document Tags and Contributors

 Contributors to this page: fscholz
 Last updated by: fscholz,