You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>This function performs the following steps when called:</p>
32774
+
<emu-alg>
32775
+
1. Let _n_ be ? ToNumber(_x_).
32776
+
1. If _n_ is *NaN*, return *NaN*.
32777
+
1. If _n_ is one of *+0*<sub>𝔽</sub>, *-0*<sub>𝔽</sub>, *+∞*<sub>𝔽</sub>, or *-∞*<sub>𝔽</sub>, return _n_.
32778
+
1. Let _n16_ be the result of converting _n_ to IEEE 754-2019 binary16 format using roundTiesToEven mode.
32779
+
1. Let _n64_ be the result of converting _n16_ to IEEE 754-2019 binary64 format.
32780
+
1. Return the ECMAScript Number value corresponding to _n64_.
32781
+
</emu-alg>
32782
+
<emu-note>
32783
+
<p>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_ = *1.00048828125000022204*<sub>𝔽</sub>, for example, for which Math.f16round(_k_) is *1.0009765625*<sub>𝔽</sub>, but Math.f16round(Math.fround(_k_)) is *1*<sub>𝔽</sub>.</p>
32784
+
<p>Not all platforms provide native support for casting from binary64 to binary16. There are various libraries which can provide this, including the MIT-licensed <a href="https://half.sourceforge.net/">half</a> 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.</p>
32785
+
</emu-note>
32786
+
</emu-clause>
32787
+
32755
32788
<emu-clause id="sec-math.hypot">
32756
32789
<h1>Math.hypot ( ..._args_ )</h1>
32757
32790
<p>Given zero or more arguments, this function returns the square root of the sum of squares of its arguments.</p>
1. Let _elementSize_ be the Element Size value specified in <emu-xref href="#table-the-typedarray-constructors"></emu-xref> for Element Type _type_.
44161
44211
1. If _isLittleEndian_ is *false*, reverse the order of the elements of _rawBytes_.
44212
+
1. If _type_ is ~float16~, then
44213
+
1. Let _value_ be the byte elements of _rawBytes_ concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2019 binary16 value.
44214
+
1. If _value_ is an IEEE 754-2019 binary16 NaN value, return the *NaN* Number value.
44215
+
1. Return the Number value that corresponds to _value_.
44162
44216
1. If _type_ is ~float32~, then
44163
44217
1. Let _value_ be the byte elements of _rawBytes_ concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2019 binary32 value.
44164
44218
1. If _value_ is an IEEE 754-2019 binary32 NaN value, return the *NaN* Number value.
@@ -44242,7 +44296,9 @@ <h1>
44242
44296
<dl class="header">
44243
44297
</dl>
44244
44298
<emu-alg>
44245
-
1. If _type_ is ~float32~, then
44299
+
1. If _type_ is ~float16~, then
44300
+
1. Let _rawBytes_ be a List whose elements are the 2 bytes that are the result of converting _value_ to IEEE 754-2019 binary16 format using roundTiesToEven mode. The bytes are arranged in little endian order. If _value_ is *NaN*, _rawBytes_ may be set to any implementation chosen IEEE 754-2019 binary16 format Not-a-Number encoding. An implementation must always choose the same encoding for each implementation distinguishable *NaN* value.
44301
+
1. Else if _type_ is ~float32~, then
44246
44302
1. Let _rawBytes_ be a List whose elements are the 4 bytes that are the result of converting _value_ to IEEE 754-2019 binary32 format using roundTiesToEven mode. The bytes are arranged in little endian order. If _value_ is *NaN*, _rawBytes_ may be set to any implementation chosen IEEE 754-2019 binary32 format Not-a-Number encoding. An implementation must always choose the same encoding for each implementation distinguishable *NaN* value.
44247
44303
1. Else if _type_ is ~float64~, then
44248
44304
1. Let _rawBytes_ be a List whose elements are the 8 bytes that are the IEEE 754-2019 binary64 format encoding of _value_. The bytes are arranged in little endian order. If _value_ is *NaN*, _rawBytes_ may be set to any implementation chosen IEEE 754-2019 binary64 format Not-a-Number encoding. An implementation must always choose the same encoding for each implementation distinguishable *NaN* value.
0 commit comments