[libc-commits] [libc] [libc][math] Add Generic Comparison Operations for floating point types (PR #144983)
Krishna Pandey via libc-commits
libc-commits at lists.llvm.org
Fri Jul 4 10:47:58 PDT 2025
================
@@ -0,0 +1,331 @@
+//===-- Unittests for Comparison Operations for FPBits class -------------===//
+//
+// 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 "src/__support/FPUtil/ComparisonOperations.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/properties/types.h"
+#include "src/__support/sign.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using LIBC_NAMESPACE::fputil::equals;
+using LIBC_NAMESPACE::fputil::greater_than;
+using LIBC_NAMESPACE::fputil::greater_than_or_equals;
+using LIBC_NAMESPACE::fputil::less_than;
+using LIBC_NAMESPACE::fputil::less_than_or_equals;
+
+#define TEST_EQUALS(Name, Type) \
+ TEST(LlvmLibc##Name##ComparisionOperationsTest, Equals) { \
+ using Bits = LIBC_NAMESPACE::fputil::FPBits<Type>; \
+ Type pos_zero = Bits::zero().get_val(); \
+ Type neg_zero = -pos_zero; \
+ Type pos_inf = Bits::inf().get_val(); \
+ Type neg_inf = Bits::inf(Sign::NEG).get_val(); \
+ Type qnan = Bits::quiet_nan().get_val(); \
+ Type snan = Bits::signaling_nan().get_val(); \
+ Type pos_normal = Type(3.14); \
+ Type neg_normal = Type(-2.71); \
+ Type pos_large = Type(1000000.0); \
+ Type neg_large = Type(-1000000.0); \
----------------
krishna2803 wrote:
done in [9d805617](https://github.com/llvm/llvm-project/pull/144983/commits/9d8056179c1adc92905d82bcf1c1be1baaf4ba0a)
https://github.com/llvm/llvm-project/pull/144983
More information about the libc-commits
mailing list