[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:57:05 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) {
----------------
bojle wrote:

as i understand, a precise value is what can be represented in fixed point form
without losing precision after we multiply it with scale and store it as int.

For example, 3.1415 in unsigned Q8.8, will be `3.1415 * 256 = 802.22 = 802`.
This is not precise. But `0.5 * 256 = 128` this is. In the same vain, isn't
0.75 (3/4) precise too? please help me understand


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


More information about the libc-commits mailing list