Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions libc/src/__support/str_to_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ clinger_fast_path(ExpandedFloat<T> init_num,
T float_mantissa;
if constexpr (cpp::is_same_v<StorageType, UInt<128>>) {
float_mantissa =
(static_cast<T>(uint64_t(mantissa)) * static_cast<T>(0x1.0p64)) +
static_cast<T>(uint64_t(mantissa >> 64));
(static_cast<T>(uint64_t(mantissa >> 64)) * static_cast<T>(0x1.0p64)) +
static_cast<T>(uint64_t(mantissa));
} else {
float_mantissa = static_cast<T>(mantissa);
}
Expand Down Expand Up @@ -591,7 +591,7 @@ clinger_fast_path(ExpandedFloat<T> init_num,
}

ExpandedFloat<T> output;
output.mantissa = result.get_mantissa();
output.mantissa = result.get_explicit_mantissa();
output.exponent = result.get_biased_exponent();
return output;
}
Expand Down
14 changes: 7 additions & 7 deletions libc/test/src/__support/str_to_double_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ namespace LIBC_NAMESPACE_DECL {
using LlvmLibcStrToDblTest = LlvmLibcStrToFloatTest<double>;

TEST_F(LlvmLibcStrToDblTest, ClingerFastPathFloat64Simple) {
clinger_fast_path_test(123, 0, 0xEC00000000000, 1029);
clinger_fast_path_test(1234567890123456, 1, 0x5ee2a2eb5a5c0, 1076);
clinger_fast_path_test(1234567890, -10, 0xf9add3739635f, 1019);
clinger_fast_path_test(123, 0, 0x1EC00000000000, 1029);
clinger_fast_path_test(1234567890123456, 1, 0x15ee2a2eb5a5c0, 1076);
clinger_fast_path_test(1234567890, -10, 0x1f9add3739635f, 1019);
}

TEST_F(LlvmLibcStrToDblTest, ClingerFastPathFloat64ExtendedExp) {
clinger_fast_path_test(1, 30, 0x93e5939a08cea, 1122);
clinger_fast_path_test(1, 37, 0xe17b84357691b, 1145);
clinger_fast_path_test(1, 30, 0x193e5939a08cea, 1122);
clinger_fast_path_test(1, 37, 0x1e17b84357691b, 1145);
clinger_fast_path_fails_test(10, 37);
clinger_fast_path_fails_test(1, 100);
}

TEST_F(LlvmLibcStrToDblTest, ClingerFastPathFloat64NegativeExp) {
clinger_fast_path_test(1, -10, 0xb7cdfd9d7bdbb, 989);
clinger_fast_path_test(1, -20, 0x79ca10c924223, 956);
clinger_fast_path_test(1, -10, 0x1b7cdfd9d7bdbb, 989);
clinger_fast_path_test(1, -20, 0x179ca10c924223, 956);
clinger_fast_path_fails_test(1, -25);
}

Expand Down
14 changes: 7 additions & 7 deletions libc/test/src/__support/str_to_float_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ namespace LIBC_NAMESPACE_DECL {
using LlvmLibcStrToFltTest = LlvmLibcStrToFloatTest<float>;

TEST_F(LlvmLibcStrToFltTest, ClingerFastPathFloat32Simple) {
clinger_fast_path_test(123, 0, 0x760000, 133);
clinger_fast_path_test(1234567, 1, 0x3c6146, 150);
clinger_fast_path_test(12345, -5, 0x7cd35b, 123);
clinger_fast_path_test(123, 0, 0xf60000, 133);
clinger_fast_path_test(1234567, 1, 0xbc6146, 150);
clinger_fast_path_test(12345, -5, 0xfcd35b, 123);
}

TEST_F(LlvmLibcStrToFltTest, ClingerFastPathFloat32ExtendedExp) {
clinger_fast_path_test(1, 15, 0x635fa9, 176);
clinger_fast_path_test(1, 17, 0x31a2bc, 183);
clinger_fast_path_test(1, 15, 0xe35fa9, 176);
clinger_fast_path_test(1, 17, 0xb1a2bc, 183);
clinger_fast_path_fails_test(10, 17);
clinger_fast_path_fails_test(1, 50);
}

TEST_F(LlvmLibcStrToFltTest, ClingerFastPathFloat32NegativeExp) {
clinger_fast_path_test(1, -5, 0x27c5ac, 110);
clinger_fast_path_test(1, -10, 0x5be6ff, 93);
clinger_fast_path_test(1, -5, 0xa7c5ac, 110);
clinger_fast_path_test(1, -10, 0xdbe6ff, 93);
clinger_fast_path_fails_test(1, -15);
}

Expand Down
15 changes: 15 additions & 0 deletions libc/test/src/__support/str_to_long_double_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat80Fallback) {
ASSERT_FALSE(internal::eisel_lemire<long double>({1, -1000}).has_value());
}

TEST_F(LlvmLibcStrToLongDblTest, ClingerFastPathFloat80Simple) {
clinger_fast_path_test(123, 0, 0xf600000000000000, 16389);
clinger_fast_path_test(1234567, 1, 0xbc61460000000000, 16406);
clinger_fast_path_test(12345, -5, 0xfcd35a858793dd98, 16379);
}

#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)

TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat128Simple) {
Expand All @@ -78,6 +84,15 @@ TEST_F(LlvmLibcStrToLongDblTest, EiselLemireFloat128Fallback) {
.has_value());
}

TEST_F(LlvmLibcStrToLongDblTest, ClingerFastPathFloat128Simple) {
clinger_fast_path_test(123, 0, 0x1ec00'00000000'00000000'00000000_u128,
16389);
clinger_fast_path_test(1234567, 1, 0x178c2'8c000000'00000000'00000000_u128,
16406);
clinger_fast_path_test(12345, -5, 0x1f9a6'b50b0f27'bb2fec56'd5cfaace_u128,
16379);
}

#else
#error "Unknown long double type"
#endif
Expand Down
Loading