|
Boost : |
From: Matt Borland (matt_at_[hidden])
Date: 2025-01-20 17:57:28
On Monday, January 20th, 2025 at 11:52 AM, Klemens Morgenstern via Boost <boost_at_[hidden]> wrote:
>
>
> On Wed, Jan 15, 2025 at 5:34â¯PM John Maddock via Boost <
> boost_at_[hidden]> wrote:
>
> > The review of the proposed Decimal Number library by Matt Borland and
> > Chris Kormanyos begins today and runs until 22nd Jan.
> >
> > You will find documentation here:
> > https://cppalliance.org/decimal/decimal.html
> >
> > And the code repository is here: https://github.com/cppalliance/decimal/
> >
> > Boost.Decimal is an implementation of IEEE 754
> > https://standards.ieee.org/ieee/754/6210/ and ISO/IEC DTR 24733
> > https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2849.pdf
> > Decimal Floating Point numbers. The library is header-only, has no
> > dependencies, and requires C++14.
>
>
> Thanks to Matt & Chris for submitting your library for review. From
> glancing at the docs it looks great. However, I got a very basic question:
>
> What are the actual applications for decimal floating points? Where are
> they used or where would potential users want to use them?
>
The canonical example is finance. We have an example[1] where a user can parse a CSV of stock pricing data without the rounding error that would come with binary floating point, and then are able to perform analysis leveraging Boost.Math.
> Why wouldn't one just use fixed-point arithmetic when the binary floating
> points don't provide the proper rounding behaviour?
>
In one of Reuben's questions he asked about emulating fixed-point and I believe that is possible, but have not tried to do it myself. We have a user who was using fixed-point arithmetic, but when they needed to support bitcoins it exceeded the precision of their fixed-point system so they either had to re-write or use an off the shelf solution like we offer here. They chose the latter and to my knowledge it has worked out for them.
Matt
[1] https://github.com/cppalliance/decimal/blob/develop/examples/statistics.cpp
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk