def f16_up

bendtorch@1.3.0.0 · dtype.bend:107

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

107# F16 -> F32, exact. A subnormal is m · 2^-24: the product of two F32 numbers that is exact and normal.
108def f16_up(zero: Bool, top: Bool, +m: U32, +s: U32, +eu: U32) -> F32:
109  match zero top:
110    case True{} _:
111      u2f((s .|. f2u((U32.to_f32(m) * 0.000000059604644775390625 : F32)) : U32))
112    case False{} True{}:
113      u2f((((s .|. 2139095040 : U32) .|. U32.shln(m, 13n) : U32) .|. pick_u(U32.is_eq(m, 0), 0, 4194304) : U32))
114    case False{} False{}:
115      u2f(((s .|. U32.shln((eu + 112 : U32), 23n) : U32) .|. U32.shln(m, 13n) : U32))

Uses (12)

Used by (1)