Skip to content

Desired feature: ability to disable sign printing on floating point zeros. (custom formatting) #331

Closed
@spacemoose

Description

We recently experimented with using fmtlib to alleviate a performance problem we were having with boost::format. I'm quite impressed with the library, but I have a feature need that prevents me from using it as is.

We need the ability to NOT print a sign when a floating point representation is textually zero. For example you have a number which is zero, but because of floating point precision issues, it's represented in memory is -0.000001. When we print "0.00" we get an unwanted sign -- "-0.00". We were able to solve this for boost::format by creating a custom num_put facet, but that approach won't work for fmtlib.

We can patch the library to get it to behave the way we want, but I suppose the reasons why this is undesirable is obvious.

So -- would you be interested in a patch that adds this functionality? Obviously we would first have to discuss the interface for controlling such a feature. I have some thoughts regarding the ability to add custom formatters to fmtlib similar to std::locale's facet functionality, but perhaps you already have thoughts on this topic If you think this might be interesting, let's start a dialogue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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