Skip to content

Commit

Permalink
Local modifications to fmt lib
Browse files Browse the repository at this point in the history
  • Loading branch information
perlun committed Sep 1, 2023
1 parent 7db49f7 commit fb4750d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/stdlib/src/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2496,9 +2496,11 @@ template <typename Char, typename OutputIt>
FMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan,
format_specs<Char> specs,
const float_specs& fspecs) -> OutputIt {
// Local modification: use NaN and Infinity for closer C# compatibility
auto str =
isnan ? (fspecs.upper ? "NAN" : "nan") : (fspecs.upper ? "INF" : "inf");
constexpr size_t str_size = 3;
isnan ? (fspecs.upper ? "NaN" : "nan") : (fspecs.upper ? "Infinity" : "inf");
const size_t str_size = strlen(str);

auto sign = fspecs.sign;
auto size = str_size + (sign ? 1 : 0);
// Replace '0'-padding with space for non-finite values.
Expand Down Expand Up @@ -3656,6 +3658,9 @@ FMT_CONSTEXPR20 auto write(OutputIt out, T value) -> OutputIt {
value = -value;
}

// Local modification: we want uppercase E sign for compatibility with C# Double.ToString()
fspecs.upper = true;

constexpr auto specs = format_specs<Char>();
using floaty = conditional_t<std::is_same<T, long double>::value, double, T>;
using floaty_uint = typename dragonbox::float_info<floaty>::carrier_uint;
Expand Down

0 comments on commit fb4750d

Please sign in to comment.