Boost logo

Boost :

From: Julien Blanc (julien.blanc_at_[hidden])
Date: 2024-05-16 08:08:42


13 mai 2024 à 15:44 "Matt Borland via Boost" <boost_at_[hidden]> a écrit:

> The library provides types decimal32, decimal64, and decimal128 as specified
> in IEEE 754 and STL-like functionality. The library is header-only, has no
> dependencies, and only requires C++14. It provides most of the STL functionality
> that you are familiar with such as <cmath>, <cstdlib>, <charconv>, etc.

Thanks for sharing.

During the boost charconv review, it was pointed out that std from_chars has a serious design defect in case of ERANGE, because the return value cannot differentiate between different range errors (value too big, too small, positive / negative, etc.), despite the information being reliably available from the parsing.

IIRC boost charconv works around this by modifiying the provided value argument, which is forbidden by std.

Is the same workaround used for decimal? (in which case the documentation should state this). Or should it be seen as an opportunity for fixing the from_chars interface / providing a better error reporting?

Another note about the documentation: some examples should use literal suffixes

The current way:

    constexpr decimal64 b {2, -1}; // 2e-1 or 0.2

is pretty unreadable / ugly. Also, there should be a statement on the differences between:

    constexpr auto b1 = 0.2_DD;
    constexpr auto b2 = decimal64(0.2);
    constexpr auto b3 = decimal64(2, -1);

I expect the first and third ones to be identical and yield precise decimal values, and the second to yield imprecise values, although i could not find a pathological case from quick tests where we would have b2 != b3.

Regards,

Julien


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk