def tanh_finish
import stelliferous@0.0.2.0/math_fp32.bend as MathFp32import Base
81# Sign restoration and the tiny interval are word selections. For |x|<2^-12,
82# |x-tanh(x)|<|x|^3/3 is below half an F32 ulp, so return x, including -0.
83def tanh_finish(+x: F32,+value: F32) -> F32:
84 +word = F32.bits(x)
85 +small = (0 - U32.shrn((U32.and(word,2147483647) - 964689920 : U32),31n) : U32)
86 +keep = U32.or(small,2147483648)
87 from_bits(U32.or(U32.and(word,keep),U32.and(F32.bits(value),U32.not(keep))))