|
Boost : |
From: Matt Borland (matt_at_[hidden])
Date: 2024-05-15 06:50:36
>
> > What is the distinction to [Boost.Multiprecision]
>
> We are glad you asked. Matt will add morebut I'll start (in fact I will expound).
> Decimal intends to provide the decimaltypes that are explicitly specified inIEEE-754:2008. These will allow clientsto perform base-10 numericalcalculations that retain portability.Here we mean portability in the senseof changing your company, compiler,operating system or whatever and still being able to use your portable code.
> C++ has that attribut, partially, todayfor binary floats but not yet for decimal.
> And a secondary intent of Decimalis to provide a reference applicationfor potential specification(in the sense of C++/SG21/LEWG)for actually getting these intothe Standard.
>
> Boost.Multiprecision does not intendto provide those types that are exactlyspecified in IEEE-754:2008.
>
> We had this discussion along theway and as recently as yesterdaysince we are both co-autohrs ofall of Decimal/Math/Multiprecision.Should Decimal be part of Multiprecisionor vice-versa? We found the answerto be NO. Decimal is not Multiprecision.
> So when we approach LEWGand say, look we have decimal(32/64/128)_t,this will ultimately beg a larger, yet unanswered,question. OK, great, decimal(32/64/128)_t.So where is float(32/64/128)_t ina mandatory spec? And the corrolaryquerry what about Int/uint(32/64/128)_t.
> These questions will ultimately needto be answered. But that's a long-termdiscussion. Following all that, the intentis that Multiprecision will swing in forunlimited precision byone the so-calledbasics of 32/64/128.
>
> Best, Christopher.
The closest approximation in multiprecision is cpp_dec_float (non-IEEE 754 compliant): https://www.boost.org/doc/libs/1_85_0/libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_dec_float.html. Chris is actually the original author of this type. The decimal library is partly an evolution from this since we know what did and did not work well. We are also able to extract a lot more performance out of decimal since instead of operating on an arbitrary number of limbs we have fixed width calculations that are specialized for each of the three types. We are also able to pre-compute polynomials for cmath functions instead of running Decimal CORDIC or other approximation algorithm at runtime: https://github.com/cppalliance/decimal/blob/develop/include/boost/decimal/detail/cmath/impl/asin_impl.hpp.
Matt
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk