Skip to content

[review][bug] digit separators are not supported #424

Description

@Becheler

Context

From Jarod on French C++ Discord:

123'456_I128 returns 123. Digit separators being all the more useful with large numbers. I don't know why the standard didn't strip ' from the template parameter of UDLs; every UDL now has to handle it itself.

Reproducer

See on Compiler Explorer: https://godbolt.org/z/bossonjGv

#include <https://raw.githubusercontent.com/Becheler/int128/refs/heads/boost_review/extra/int128_amalgamated.hpp>
#include <iostream>
#include <cassert>

int main()
{
    using namespace boost::int128::literals;

    const auto without_sep {123456_U128};
    const auto with_sep    {123'456_U128};

    std::cout << "123456_U128   = " << without_sep << '\n';
    std::cout << "123'456_U128  = " << with_sep    << std::endl;

    // Bug: the digit separator truncates parsing.
    // Expected 123456, observed 123.
    assert(with_sep == without_sep);  // fails
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Boost ReviewFeedback from the review period including pre- and post- on the MLBugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions