Skip to content

Commit 6a863f7

Browse files
authored
[libc] Fix signed zeros for exp10m1f16 and tanhf16. (#116654)
1 parent ac17b50 commit 6a863f7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

libc/src/math/generic/exp10m1f16.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ LLVM_LIBC_FUNCTION(float16, exp10m1f16, (float16 x)) {
119119

120120
// When |x| <= 2^(-3).
121121
if (x_abs <= 0x3000U) {
122+
if (LIBC_UNLIKELY(x_abs == 0))
123+
return x;
124+
122125
if (auto r = EXP10M1F16_EXCEPTS_LO.lookup(x_u);
123126
LIBC_UNLIKELY(r.has_value()))
124127
return r.value();

libc/src/math/generic/tanhf16.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ LLVM_LIBC_FUNCTION(float16, tanhf16, (float16 x)) {
6464

6565
// When |x| <= 0x1.d2p-4.
6666
if (x_abs <= 0x2f48U) {
67+
if (LIBC_UNLIKELY(x_abs == 0))
68+
return x;
69+
6770
float xf = x;
6871
float xf_sq = xf * xf;
6972
// Degree-7 Taylor expansion generated by Sollya with the following

0 commit comments

Comments
 (0)