boostorg / boostorg/charconv

Some more issues about `to_chars`

Open
#166 9 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
32
Forks
29
PR merge metrics
No merged PRs in 30d

Description

1. It seems that `std::to_chars` returns `errc::value_too_large` rather than `errc::result_out_of_range`. Is this simply a mistake or do you have a reason for using `errc::result_out_of_range` instead? In the code I edited I used `errc::result_out_of_range` for consistency.

3. `to_chars` with only buffer & value, with the format param as well, and with the precision param as well, all should be separate overloads. The reason why the first and the second should be separate overloads is because the first one should behave differently from the second one with `fmt == chars_format::general`; it needs to select whatever representation that is shortest, which does not always need to be equal to `chars_format::general`'s output. The reason why the second and the third should be separate overloads is because by the spec, `precision` being negative should be treated as if `precision == 6`, because the spec of `std::printf` says that negative precision is ignored, which means it should fall back to the default, which is 6. I guess this is quite stupid, but well, it seems that's how the spec is written anyway.

EDIT: Ah, forgot to mention. When fixed format is chosen for the shortest representation, the output of Dragonbox may not be the correctly rounded one, because there can be trailing zeros in the integer part. (See https://github.com/fmtlib/fmt/issues/3649 for a related discussion in libfmt.)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.