Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::uint64_t numbers above a certain value are not formatted correctly #235

Open
fedmos opened this issue Aug 7, 2024 · 0 comments
Open

Comments

@fedmos
Copy link

fedmos commented Aug 7, 2024

Boost version: 1.83.000
Compiler : GCC 13.2.0

std::uint64_t numbers above a certain value are not formatted correctly:
in the following minimal example first is formatted correctly (commas are used as separators), while second is not correctly formatted (no commas are used)

Example:

#include <iostream>
#include <iomanip>
#include <boost/format.hpp>
#include <boost/locale.hpp>

int main()
{
    boost::locale::generator gen;
    gen.categories(boost::locale::category_t::convert | boost::locale::category_t::formatting);
    auto locale = gen.generate("en_US.utf-8");
    
    std::stringstream output;
    output << boost::locale::as::number;
    output << std::setprecision(6);
    output.imbue(locale);
    
    std::uint64_t first = 9223372036854U;
    std::uint64_t second = 9223372036854775808U;
    
    output << first << " " << second;
    std::clog << output.str() << std::endl;
    return 0;
}

Console output:

9,223,372,036,854 9223372036854775808

Flamefire added a commit that referenced this issue Aug 8, 2024
As reported in #235 formatting the first number which doesn't fit into
int64_t anymore fails to add the thousands separators.
I.e.:
`9223372036854775807` -> `9,223,372,036,854,775,807`
`9223372036854775808` -> `9223372036854775808`

Add a test reproducing that that for all backends.
Flamefire added a commit that referenced this issue Aug 8, 2024
As reported in #235 formatting the first number which doesn't fit into
int64_t anymore fails to add the thousands separators.
I.e.:
`9223372036854775807` -> `9,223,372,036,854,775,807`
`9223372036854775808` -> `9223372036854775808`

Add a test reproducing that that for all backends.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant