[libc-commits] [libc] [libc][math][c23] Add asinhf16() function (PR #131351)

via libc-commits libc-commits at lists.llvm.org
Sun Mar 16 14:33:36 PDT 2025


================
@@ -0,0 +1,35 @@
+//===-- Unittests for asinhf16---------------------------------------------===//
+//
+// 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/errno/libc_errno.h"
+#include "src/math/asinhf16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using LlvmLibcAsinhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
+
+TEST_F(LlvmLibcAsinhf16Test, SpecialNumbers) {
+  LIBC_NAMESPACE::libc_errno = 0;
+  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::asinhf16(aNaN));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::asinhf16(sNaN), FE_INVALID);
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::asinhf16(0.0f));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ(-0.0f, LIBC_NAMESPACE::asinhf16(-0.0f));
+  EXPECT_MATH_ERRNO(0);
----------------
overmighty wrote:

Can use `zero` and `neg_zero` here to avoid implicit casts.

```suggestion
  EXPECT_FP_EQ(zero, LIBC_NAMESPACE::asinhf16(zero));
  EXPECT_MATH_ERRNO(0);

  EXPECT_FP_EQ(neg_zero, LIBC_NAMESPACE::asinhf16(neg_zero));
  EXPECT_MATH_ERRNO(0);
```

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


More information about the libc-commits mailing list