[libc-commits] [libc] [libc][math][c23] add c23 floating point fmaximum and fminimum fns (PR #86016)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Wed Mar 20 14:53:04 PDT 2024
================
@@ -58,6 +58,130 @@ LIBC_INLINE T fmax(T x, T y) {
}
}
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
+LIBC_INLINE T fmaximum(T x, T y) {
+ FPBits<T> bitx(x), bity(y);
+
+ if (bitx.is_nan()) {
+ return x;
+ } else if (bity.is_nan()) {
----------------
nickdesaulniers wrote:
Please use the form:
```
if (bitx. ...)
return ...
if (bity. ...)
return
if (bitx.sign ...)
return
return x > y ? x : y;
```
Here and below.
https://github.com/llvm/llvm-project/pull/86016
More information about the libc-commits
mailing list