[libc-commits] [libc] [libc] Modify `atan2f128` to use emulated Float128 type (PR #216508)

via libc-commits libc-commits at lists.llvm.org
Mon Aug 17 17:01:07 PDT 2026


================
@@ -151,7 +150,8 @@ LIBC_INLINE float128 atan2f128(float128 y, float128 x) {
       DFloat128 r = EXCEPTS[y_except][x_except][x_sign];
       if (y_sign)
         r.sign = r.sign.negate();
-      return static_cast<float128>(r);
+      return r.template as<Float128, /*ShouldSignalExceptions=*/false>();
+      (r);
----------------
overmighty wrote:

`static_cast<float128>(r)` is the same as `r.template as<Float128, /*ShouldSignalExceptions=*/false>();`:

https://github.com/llvm/llvm-project/blob/f431b45638ecb29f838dd4c314aac36f8a30480b/libc/src/__support/FPUtil/dyadic_float.h#L454-L460

We do need to signal `FE_INEXACT`, etc, during rounding here.

There's an unused and unreachable `(r);` after the return statement by the way.

```suggestion
      return r.template as<Float128, /*ShouldSignalExceptions=*/true>();
```

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


More information about the libc-commits mailing list