Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions libc/src/__support/FPUtil/generic/add_sub.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ add_or_sub(InType x, InType y) {
return OutFPBits::inf(x_bits.sign()).get_val();
}

if (y_bits.is_inf())
return OutFPBits::inf(y_bits.sign()).get_val();
if (y_bits.is_inf()) {
if constexpr (IsSub)
return OutFPBits::inf(y_bits.sign().negate()).get_val();
else
return OutFPBits::inf(y_bits.sign()).get_val();
}

if (x_bits.is_zero()) {
if (y_bits.is_zero()) {
Expand Down
2 changes: 2 additions & 0 deletions libc/test/src/math/smoke/SubTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class SubTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(neg_inf, func(in.neg_inf, in.zero));
EXPECT_FP_EQ(inf, func(in.inf, in.neg_zero));
EXPECT_FP_EQ(neg_inf, func(in.neg_inf, in.neg_zero));
EXPECT_FP_EQ(neg_inf, func(in.zero, in.inf));
EXPECT_FP_EQ(inf, func(in.zero, in.neg_inf));
}

void test_invalid_operations(SubFunc func) {
Expand Down
Loading