From 2be85fc62abf467286027018ef7869177155e4c8 Mon Sep 17 00:00:00 2001 From: ras44 <9282281+ras44@users.noreply.github.com> Date: Fri, 3 May 2019 05:01:26 +0200 Subject: [PATCH] max_digits10 guarantees float decimal roundtrip (#4435) 2 additional digits are not needed to guarantee that casting the decimal representation will result in the same float, see https://github.com/dmlc/xgboost/issues/3980#issuecomment-458702440 --- src/cli_main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli_main.cc b/src/cli_main.cc index faa93ad2b..ccd675715 100644 --- a/src/cli_main.cc +++ b/src/cli_main.cc @@ -327,7 +327,7 @@ void CLIPredict(const CLIParam& param) { dmlc::Stream::Create(param.name_pred.c_str(), "w")); dmlc::ostream os(fo.get()); for (bst_float p : preds.ConstHostVector()) { - os << std::setprecision(std::numeric_limits::max_digits10 + 2) + os << std::setprecision(std::numeric_limits::max_digits10) << p << '\n'; } // force flush before fo destruct.