mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
Everywhere: Use NaN<T> instead of __builtin_nan{f,,l}("")
No behavior change.
This commit is contained in:
1 parent
c793c2e626
commit
c5af100c9e
4 files changed
+7
-6
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/FloatingPointStringConversions.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Math/Constants.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/UFixedBigInt.h>
|
||||
@@ -1975,7 +1976,7 @@ template<FloatingPoint T>
|
||||
constexpr FloatingPointParseResults<T> parse_result_to_full_result(BasicParseResult parse_result)
|
||||
{
|
||||
if (!parse_result.valid)
|
||||
return { nullptr, FloatingPointError::NoOrInvalidInput, __builtin_nan("") };
|
||||
return { nullptr, FloatingPointError::NoOrInvalidInput, AK::NaN<double> };
|
||||
|
||||
FloatingPointParseResults<T> full_result {};
|
||||
full_result.end_ptr = parse_result.last_parsed;
|
||||
@@ -2251,7 +2252,7 @@ FloatingPointParseResults<T> parse_first_hexfloat_until_zero_character(char cons
|
||||
auto parse_result = parse_hexfloat(start);
|
||||
|
||||
if (!parse_result.valid)
|
||||
return { nullptr, FloatingPointError::NoOrInvalidInput, __builtin_nan("") };
|
||||
return { nullptr, FloatingPointError::NoOrInvalidInput, AK::NaN<double> };
|
||||
|
||||
FloatingPointParseResults<T> full_result {};
|
||||
full_result.end_ptr = parse_result.last_parsed;
|
||||
|
||||
@@ -439,7 +439,7 @@ TEST_CASE(test_strtod_sets_errno)
|
||||
EXPECT_EQ(bit_cast<u64>(value), bit_cast<u64>(static_cast<double>(double_value))); \
|
||||
} while (false)
|
||||
|
||||
EXPECT_TO_GIVE_VALUE_WITH_ERRNO("nan", __builtin_nan(""), ERANGE);
|
||||
EXPECT_TO_GIVE_VALUE_WITH_ERRNO("nan", AK::NaN<double>, ERANGE);
|
||||
EXPECT_TO_GIVE_VALUE_WITH_ERRNO("10e10000", AK::Infinity<double>, ERANGE);
|
||||
EXPECT_TO_GIVE_VALUE_WITH_ERRNO("0x1p10000", AK::Infinity<double>, ERANGE);
|
||||
EXPECT_TO_GIVE_VALUE_WITH_ERRNO("-10e10000", -AK::Infinity<double>, ERANGE);
|
||||
|
||||
@@ -331,9 +331,9 @@ static T c_str_to_floating_point(char const* str, char** endptr)
|
||||
errno = ERANGE;
|
||||
// FIXME: Do we actually want to return "different" NaN bit values?
|
||||
if (sign != Sign::Negative)
|
||||
return static_cast<T>(__builtin_nan(""));
|
||||
return AK::NaN<T>;
|
||||
else
|
||||
return static_cast<T>(-__builtin_nan(""));
|
||||
return -AK::NaN<T>;
|
||||
}
|
||||
|
||||
// If no conversion could be performed, 0 shall be returned, and errno may be set to [EINVAL].
|
||||
|
||||
@@ -36,7 +36,7 @@ static_assert(sizeof(void*) == sizeof(double) || sizeof(void*) == sizeof(u32));
|
||||
// doubles have a lot (2^52 - 2) of NaN bit patterns. The canonical form being
|
||||
// just 0x7FF8000000000000 i.e. sign = 0 exponent is all ones and the top most
|
||||
// bit of the mantissa set.
|
||||
static constexpr u64 CANON_NAN_BITS = bit_cast<u64>(__builtin_nan(""));
|
||||
static constexpr u64 CANON_NAN_BITS = bit_cast<u64>(AK::NaN<double>);
|
||||
static_assert(CANON_NAN_BITS == 0x7FF8000000000000);
|
||||
// (Unfortunately all the other values are valid so we have to convert any
|
||||
// incoming NaNs to this pattern although in practice it seems only the negative
|
||||
|
||||
Reference in new issue
Block a user