Skip to content

Commit

Permalink
max_digits10 guarantees float decimal roundtrip
Browse files Browse the repository at this point in the history
2 additional digits are not needed to guarantee that casting the decimal representation will result in the same float, see dmlc#3980 (comment)
  • Loading branch information
ras44 authored May 2, 2019
1 parent 54980b8 commit 7119c83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cli_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7119c83

Please sign in to comment.