[libc-commits] [libc] [libc][math][c++23] Add fmodbf16 math function (PR #155575)

Krishna Pandey via libc-commits libc-commits at lists.llvm.org
Sat Aug 30 08:57:48 PDT 2025


================
@@ -165,10 +175,10 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     TEST_SPECIAL(neg_sNaN, sNaN, aNaN, false, FE_INVALID);
     TEST_SPECIAL(neg_sNaN, neg_sNaN, aNaN, false, FE_INVALID);
 
-    TEST_SPECIAL(T(6.5), T(2.25), T(2.0), false, 0);
-    TEST_SPECIAL(T(-6.5), T(2.25), T(-2.0), false, 0);
-    TEST_SPECIAL(T(6.5), T(-2.25), T(2.0), false, 0);
-    TEST_SPECIAL(T(-6.5), T(-2.25), T(-2.0), false, 0);
+    TEST_SPECIAL(six_halves, two_quaters, two, false, 0);
+    TEST_SPECIAL(neg_six_halves, two_quaters, neg_two, false, 0);
+    TEST_SPECIAL(six_halves, neg_two_quaters, two, false, 0);
+    TEST_SPECIAL(neg_six_halves, neg_two_quaters, neg_two, false, 0);
----------------
krishna2803 wrote:

Those are needed because `T(6.5)`,  raises `FP_INEXACT` exception

```cpp
// [...]
TEST_SPECIAL(T(6.5), two_quaters, two, false, 0);
// [...]
```

```
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcFmodTest.SpecialNumbers
/home/krishna/projects/llvm-project/libc/test/src/math/smoke/FModTest.h:178: FAILURE
      Expected: __llvm_libc_22_0_0_git::fputil::test_except( static_cast<int>((0x20 | 0x04 | 0x10 | 0x08 | 0x01))) & ((0) ? (0) : static_cast<int>((0x20 | 0x04 | 0x10 | 0x08 | 0x01)))
      Which is: 32
To be equal to: (0)
      Which is: 0
[  FAILED  ] LlvmLibcFmodTest.SpecialNumbers
```
Same is true for all other `T(...)` casts

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


More information about the libc-commits mailing list