Skip to content

Feature request: rounding half to even #251

@dangelog

Description

@dangelog

Hi,

This has already been discussed in #72 , but I'd like to resubmit it as a feature request.

Double to string conversion currently rounds half away from zero: 0.25 (precise) printed with 1 digit of precision yields "0.3".
This is documented here https://github.com/google/double-conversion/blob/master/double-conversion/double-to-string.h#L404 (search for "halfway cases").

However rounding away from zero is not what most C++ code does by default: printf, std::print, std::to_chars etc. all round half to even. (One would also argue, this is what most other programming languages do.) They would print "0.2" in the above example, not "0.3".

It would be nice to have a way to pass a flag or similar in order to request this rounding form from DoubleToStringConverter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions