diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-10-30 10:43:21 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-31 12:15:34 +0100 |
commit | fed9cb5d2d3833c02b27abb4a4e19fed85a6c27e (patch) | |
tree | 8b1d566463331c249a86cec48322b59d71937f68 /AK | |
parent | 2c93ee50cd7b247bf01c6f6fabd3ae441d742ea8 (diff) | |
download | serenity-fed9cb5d2d3833c02b27abb4a4e19fed85a6c27e.zip |
AK+Tests: Fix formatting of infinity and NaN values
When I added this code in 1472f6d, I forgot to add tests for it. That's
why I didn't realize that the values were appended to the wrong
FormatBuilder object, so an empty string was returned instead of the
expected "nan"/"inf". This made debugging some FPU issues with the
ScummVM port significantly more difficult.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Format.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/AK/Format.cpp b/AK/Format.cpp index 05ee228cdc..fb95978873 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -365,14 +365,14 @@ void FormatBuilder::put_f64( string_builder.append('-'); else if (sign_mode == SignMode::Always) string_builder.append('+'); - else + else if (sign_mode == SignMode::Reserved) string_builder.append(' '); if (isnan(value)) string_builder.append(upper_case ? "NAN"sv : "nan"sv); else string_builder.append(upper_case ? "INF"sv : "inf"sv); - format_builder.put_string(string_builder.string_view(), align, min_width, NumericLimits<size_t>::max(), fill); + put_string(string_builder.string_view(), align, min_width, NumericLimits<size_t>::max(), fill); return; } @@ -431,14 +431,14 @@ void FormatBuilder::put_f80( string_builder.append('-'); else if (sign_mode == SignMode::Always) string_builder.append('+'); - else + else if (sign_mode == SignMode::Reserved) string_builder.append(' '); if (isnan(value)) string_builder.append(upper_case ? "NAN"sv : "nan"sv); else string_builder.append(upper_case ? "INF"sv : "inf"sv); - format_builder.put_string(string_builder.string_view(), align, min_width, NumericLimits<size_t>::max(), fill); + put_string(string_builder.string_view(), align, min_width, NumericLimits<size_t>::max(), fill); return; } |