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
This commit is contained in:
ras44 2019-05-03 05:01:26 +02:00 committed by Philip Hyunsu Cho
parent feb6ae3e18
commit 2be85fc62a

View File

@ -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<bst_float>::max_digits10 + 2)
os << std::setprecision(std::numeric_limits<bst_float>::max_digits10)
<< p << '\n';
}
// force flush before fo destruct.