[libc-commits] [libc] [libc][math][c23] add c23 floating point fmaximum and fminimum fns (PR #86016)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Wed Mar 20 15:01:12 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()) {
----------------
michaelrj-google wrote:

nit: You don't need `else` here, since you always return if the condition is true.

This could be
```
if(foo)
    return foo;
if(bar)
    return bar;
...
```

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


More information about the libc-commits mailing list