def f16_normal

bendtorch@1.3.0.0 · dtype.bend:66

import bendtorch@1.3.0.0/dtype.bend as Dtype
import Base

66# a normal F16 (|x| >= 2^-14): rebias the exponent (127 - 15 = 112), round the 23-bit mantissa to 10 bits to nearest
67# even; past 65504 the carry reaches the infinity pattern 0x7C00 and anything above it is infinity too
68def f16_normal(+a: U32) -> U32:
69  +m = (a - 939524096 : U32)
70  +r = U32.shrn(((m + 4095 : U32) + (U32.shrn(m, 13n) .&. 1 : U32) : U32), 13n)
71  pick_u(U32.is_gt(r, 31744), 31744, r)

Uses (7)

Used by (1)