[libc-commits] [libc] [libc][math] Fix low-precision range reporting and rounding (PR #236472)

via libc-commits libc-commits at lists.llvm.org
Thu Nov 5 08:46:16 PST 2026


================
@@ -64,6 +64,12 @@ LIBC_INLINE bfloat16 expbf16(bfloat16 x) {
   uint16_t x_u = x_bits.uintval();
   uint16_t x_abs = x_u & 0x7fffU;
 
+  // For |x| <= 2^-12, exp(x) rounds like 1 + x in bfloat16.
+  // Use double so tiny products in the float polynomial cannot underflow.
+  if (LIBC_UNLIKELY(x_abs <= 0x3980U))
----------------
lntue wrote:

Move this inside `// 0 < |x| <= 2^(-3)` block below.

https://github.com/llvm/llvm-project/pull/236472


More information about the libc-commits mailing list