|
Boost : |
From: Kostas Savvidis (kotika98_at_[hidden])
Date: 2024-05-14 11:29:09
> On May 13, 2024, at 16:44, Matt Borland via Boost <boost_at_[hidden]> wrote:
>
> Hello,
>
> For the past year Chris Kormanyos and I have been working on a new library to implement IEEE 754 decimal floating point types. We are pleased to announce the library is now in beta, and can be found at: https://github.com/cppalliance/decimal, and the documentation is at: https://cppalliance.org/decimal/decimal.html
A first look convinces me that you have done a competent job, and that I might use the library, but I have concerns about the accompanying wording.
> First, what are Decimal Floating Point Numbers? They are floating point numbers where the significand is stored in base-10 (decimal) instead of base-2 (binary). This means that numbers can be represented exactly ...
This does not mean that real numbers can be represented exactly, only that
some DECIMAL fractions can be represented exactly.
The advantage (if any) is coming not from storing the significand in base-10 but from the base of the floating exponent being 10:
n*10^e where n and e are integers. BTW, there is no requirement to store n and e in decimal.
Similarly, in the Documentation, I see the dubious statement:
"... floating point types store the significand ... as binary digits. Famously this leads to rounding errors:"
The behaviour of 0.1+0.2 mentioned is not even a rounding error, probably the technical term is "representation error".
And also, in the Use Cases section:
"The use case for Decimal Floating Point numbers is where rounding errors are significantly impactful such as finance.
In applications where integer or fixed-point arithmetic are used to combat this issue
Decimal Floating Point numbers can provide a significantly greater range of values."
I dont see how one could say they provide a significantly greater range of values.
Already, somebody replied that "This is a really needed library for native C++ big number math" ???
Sorry, but no. What DFP promise to do is correct elementary arithmetic with decimal fractions.
As such, it is not clear who possibly needs math special functions in decimal... but ok, the standard says so.
Instead, how do I do fixed-point arithmetic with Decimal Floating Point, i.e.
what are the facilities in this library for calculating mortgage interest in dollars and cents, rounding the cents correctly at each stage?
As it is, the doc is completely silent about this.
Finally, no references in the documentation, a good review of the state-of-the-art might be:
Decimal Floating-Point: Algorism for Computers
Michael F. Cowlishaw
https://www.cs.tufts.edu/~nr/cs257/archive/mike-cowlishaw/decimal-arith.pdf
Cheers,
Kostas
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk