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 SIMD.Float32x4
data type is a 128-bit vector divided into 4 lanes storing single precision floating point values.
Figure 1: SIMD.Float32x4 in a 128-bit SIMD register.
SIMD.Float32x4(x, y, z, w);
The input values are specified in double precision floating and are converted to single precision floating point values before being stored.
x
Optional
NaN
.y
Optional
NaN
.z
Optional
NaN
.w
Optional
NaN
.In addition to the simple creator functions, the SIMD API provides the following constructor function. Note that you can also convert from another SIMD data type to Float32x4.
SIMD.Float32x4.splat()
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.Float32x4(0, 1, 2, 3); // TypeError: SIMD.Float32x4 is not a constructor var w = new SIMD.Float32x4.splat(3); // TypeError: SIMD.Float32x4.splat is not a constructor
Instead, you just write:
var v = SIMD.Float32x4(0, 1, 2, 3); var w = SIMD.Float32x4.splat(3);
To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.
SIMD.Float32x4.check()
TypeError
otherwise.SIMD.Float32x4.extractLane()
SIMD.Float32x4.replaceLane()
SIMD.Float32x4.load()
SIMD.Float32x4.load1()
SIMD.Float32x4.load2()
SIMD.Float32x4.load3()
SIMD.Float32x4.store()
SIMD.Float32x4.store1()
SIMD.Float32x4.store2()
SIMD.Float32x4.store3()
SIMD.Float32x4.abs()
SIMD.Float32x4.add()
a + b
).SIMD.Float32x4.div()
a / b
).SIMD.Float32x4.mul()
a * b
).SIMD.Float32x4.neg()
SIMD.Float32x4.reciprocalApproximation()
SIMD.Float32x4.reciprocalSqrtApproximation()
SIMD.Float32x4.sub()
a - b
).SIMD.Float32x4.sqrt()
SIMD.Float32x4.shuffle()
SIMD.Float32x4.swizzle()
SIMD.Float32x4.max()
SIMD.Float32x4.maxNum()
NaN
.SIMD.Float32x4.min()
SIMD.Float32x4.minNum()
NaN
.SIMD.Float32x4.select()
SIMD.Float32x4.equal()
a == b
.SIMD.Float32x4.notEqual()
a != b
.SIMD.Float32x4.lessThan()
a < b
.SIMD.Float32x4.lessThanOrEqual()
a <= b
.SIMD.Float32x4.greaterThan()
a > b
.SIMD.Float32x4.greaterThanOrEqual()
a >= b
.SIMD.Float32x4.fromFloat64x2Bits()
SIMD.Float32x4.fromInt32x4()
SIMD.Float32x4.fromInt32x4Bits()
SIMD.Float32x4.fromInt16x8Bits()
SIMD.Float32x4.fromInt8x16Bits()
SIMD.Float32x4.fromUint32x4()
SIMD.Float32x4.fromUint32x4Bits()
SIMD.Float32x4.fromUint16x8Bits()
SIMD.Float32x4.fromUint8x16Bits()
The following methods and properties are installed on the SIMD.Float32x4.prototype
.
SIMD.Float32x4.prototype.constructor
SIMD.Float32x4.prototype.toLocaleString()
Object.prototype.toLocaleString()
method.SIMD.Float32x4.prototype.toString()
Object.prototype.toString()
method.SIMD.Float32x4.prototype.valueOf()
SIMD.Float32x4.prototype.toSource()
Object.prototype.toSource()
method.SIMD.Float32x4(1, 2, 3, 4); // Float32x4[1, 2, 3, 4] SIMD.Float32x4(1, 2); // Float32x4[1, 2, NaN, NaN] SIMD.Float32x4(); // Float32x4[NaN, NaN, NaN, NaN]
Specification | Status | Comment |
---|---|---|
SIMD The definition of 'Float32x4' in that specification. | Draft | 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–2017 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/Float32x4