?
u
/
You can discuss this proposal on GitHub.
This proposal adds a new kind of TypedArray. TypedArrays are specified in a slightly different way from the rest of the standard library, so the specification for this proposal consists of a surprisingly small change.
The following subclause is inserted.
See
This function performs the following steps when called:
This operation is not the same as casting to binary32 and then to binary16 because of the possibility of double-rounding: consider the number k =
Not all platforms provide native support for casting from binary64 to binary16. There are various libraries which can provide this, including the MIT-licensed half library. Alternatively, it is possible to first cast from binary64 to binary32 under roundTiesToEven and then check whether the result could lead to incorrect double-rounding. The cases which could can be handled explicitly by adjusting the mantissa of the binary32 value so that it is the value which would be produced by performing the initial cast under roundTiesToOdd. Casting the adjusted value to binary16 under roundTiesToEven then produces the correct value.
The table below is modified by the addition of a row for float16.
|
Element Type | Element Size | Conversion Operation | Description |
---|---|---|---|---|
Int8Array %Int8Array% |
|
1 |
|
8-bit two's complement signed |
Uint8Array %Uint8Array% |
|
1 |
|
8-bit unsigned |
Uint8ClampedArray %Uint8ClampedArray% |
|
1 |
|
8-bit unsigned |
Int16Array %Int16Array% |
|
2 |
|
16-bit two's complement signed |
Uint16Array %Uint16Array% |
|
2 |
|
16-bit unsigned |
Int32Array %Int32Array% |
|
4 |
|
32-bit two's complement signed |
Uint32Array %Uint32Array% |
|
4 |
|
32-bit unsigned |
BigInt64Array %BigInt64Array% |
|
8 |
|
64-bit two's complement signed |
BigUint64Array %BigUint64Array% |
|
8 |
|
64-bit unsigned |
Float16Array %Float16Array% |
|
2 | 16-bit IEEE floating point | |
Float32Array %Float32Array% |
|
4 | 32-bit IEEE floating point | |
Float64Array %Float64Array% |
|
8 | 64-bit IEEE floating point |
The abstract operation RawBytesToNumeric takes arguments type (a
The algorithm below is modified by the addition of a case for
The abstract operation NumericToRawBytes takes arguments type (a
The algorithm below is modified by the addition of a case for
The following two subclauses are inserted.
This method performs the following steps when called:
This method performs the following steps when called: