[libc-commits] [libc] [libc][stdfix] Implement fxdivi functions (rdivi) (PR #154914)

Shreeyash Pandey via libc-commits libc-commits at lists.llvm.org
Tue Aug 26 05:47:59 PDT 2025


================
@@ -0,0 +1,49 @@
+//===-- Utility class to test fxdivi functions ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "test/UnitTest/Test.h"
+
+#include "src/__support/fixed_point/fx_rep.h"
+#include "src/__support/macros/sanitizer.h"
+
+#include "hdr/signal_macros.h"
+
+template <typename XType>
+class DivITest : public LIBC_NAMESPACE::testing::Test {
+  using FXRep = LIBC_NAMESPACE::fixed_point::FXRep<int>;
+
+public:
+  typedef XType (*DivIFunc)(int, int);
+
+  void testBasic(DivIFunc func) {
+    auto c1 = func(2, 3);
+    auto e1 = 0.666666;
----------------
bojle wrote:

are you expecting something like:
```
if (abs(func(2,3) - expected) < epsilon) {
  // pass
}
```
in this case, epsilon would be ULP of long accum, as that is what we use for
calculation, or would it be based on XType?


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


More information about the libc-commits mailing list