Converts a float32 to the nearest half, rounding ties to even.
- From 65520 up the result is infinity (or a failed assert with
ASSERT_ON_OVERFLOW). - Tiny values become subnormals, and ones too small for that become zero.
- A NaN stays a NaN.
assert(cast(u16) float_to_half_fast3(1.0) == 0x3c00);
assert(cast(u16) float_to_half_fast3(-2.0) == 0xc000);
assert(cast(u16) float_to_half_fast3(65504.0) == 0x7bff);
assert(cast(u16) float_to_half_fast3(1.0 / 3.0) == 0x3555);
assert(cast(u16) float_to_half_fast3(100000.0) == 0x7c00); // overflow: infinity
assert(cast(u16) float_to_half_fast3(cast(float32) 1.00048828125) == 0x3c00); // tie rounds to evenfloat_to_half_fast3 :: (_f: float32) -> Float16
Parameters
- _f: float32