diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-08 09:42:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-08 09:42:17 +0100 |
commit | 665ee70edb3ab4f7964bb5f324ea92a1e91076c3 (patch) | |
tree | 47e5ba23fa48e43d75afd0e1d76542af1a7858ca | |
parent | 6952fc472741ad2947615b9935559640116f3556 (diff) | |
parent | bdb7adecfb2834640279a26886ff110693e43910 (diff) |
Merge pull request #33376 from jamie-pate/master
Fix #24137 Different number of leading zeros on MINGW printf("%lg")
-rw-r--r-- | core/ustring.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 7ee2fee312..7850c6774c 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1337,7 +1337,17 @@ String String::num_scientific(double p_num) { char buf[256]; #if defined(__GNUC__) || defined(_MSC_VER) + +#if (defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900)) && defined(_TWO_DIGIT_EXPONENT) + // MinGW and old MSC require _set_output_format() to conform to C99 output for printf + unsigned int old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT); +#endif snprintf(buf, 256, "%lg", p_num); + +#if (defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900)) && defined(_TWO_DIGIT_EXPONENT) + _set_output_format(old_exponent_format); +#endif + #else sprintf(buf, "%.16lg", p_num); #endif |