SIMD.js has been taken out of active development in TC39 and removed from Stage 3. It is not being pursued by web browsers for implementation anymore. SIMD operations exposed to the web are under active development within WebAssembly, with operations based on the SIMD.js operations.
The static SIMD.%type%.shiftRightByScalar()
method returns a new instance with the lane values shifted right. Depending on the type, these operations are used:
a >> bits
, signed right shift operator).a >>> bits
, unsigned right shift operator).SIMD.Int8x16.shiftRightByScalar(a, bits) SIMD.Int16x8.shiftRightByScalar(a, bits) SIMD.Int32x4.shiftRightByScalar(a, bits) SIMD.Uint8x16.shiftRightByScalar(a, bits) SIMD.Uint16x8.shiftRightByScalar(a, bits) SIMD.Uint32x4.shiftRightByScalar(a, bits)
bits
A new corresponding SIMD data type with the lane values shifted right by a given bit count.
The bitwise arithmetic right shift operation shifts the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name "sign-propagating" or "arithmetic".
For non-negative numbers, the arithmetic right shift and the logical right shift yield the same result.
For example, a bitwise right arithmetic shift of 5 >> 1
results in 0010
which is 2 in decimal.
5 0101 ---- 2 0010
The bitwise logical right shift operation shifts the specified number of bits to the right. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left. The sign bit becomes 0, so the result is always non-negative.
For non-negative numbers, the arithmetic right shift and the logical right shift yield the same result.
For example, a bitwise right logical shift of -8 >>> 1
results in 01111111111111111111111111111100
which is 2147483644
in decimal.
-8 11111111111111111111111111111000 -------------------------------- 2147483644 01111111111111111111111111111100
Int32x4
var a = SIMD.Int32x4(1, 2, 4, -8); SIMD.Int32x4.shiftRightByScalar(a, 1); // Int32x4[0, 1, 2, -4]
Uint32x4
var a = SIMD.Uint32x4(1, 2, 4, -8); SIMD.Uint32x4.shiftRightByScalar(a, 1); // Uint32x4[0, 1, 2, 2147483644]
Specification | Status | Comment |
---|---|---|
SIMD The definition of 'SIMDConstructor.shiftRightByScalar' in that specification. | Obsolete | Initial definition. |
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 |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SIMD/shiftRightByScalar