def f16_of_bits
import bendtorch@1.3.0.0/dtype.bend as Dtypeimport Base
99# F32 -> F16, round to nearest even, with the sign kept (so -0.0 and the negative tiny numbers give 0x8000)
100def f16_of_bits(+u: U32) -> U32:
101 +a = (u .&. 2147483647 : U32)
102 ((U32.shrn(u, 16n) .&. 32768 : U32) .|. f16_mag(U32.is_gt(a, 2139095040), U32.is_ge(a, 947912704), U32.is_le(a, 855638016), a) : U32)