There's theory and math, and then there's reality.

In reality, some accounting systems use decimals with fixed
precision for certain aspects and apply predefined rounding
(usually defined in the contracts between the counterparties
or in accounting/tax regulations), while others use IEEE 754 double
precision floats. Rounding errors are dealt with by booking
corrections where necessary.

As an example, it's possible that VAT regulations mandate to
do the VAT calculation at the per item level (including
rounding at that level) and not at the summary level. This can
result in significant differences when you have to deal with
lots of small amounts. The VAT sum will diverge considerably
from the VAT you'd do get from using the sum of the net items
as basis - but this is intended.

In high finance, I've never seen decimals being used, only floats.
Excel is omnipresent, sets the standards and uses IEEE 754 floats
as well (plus some black magic which sometimes helps, but often
makes things worse):
https://en.wikipedia.org/wiki/Numeric_precision_in_Microsoft_Excel

As a result, there's no one-fits-all answer to decimal vs.
floats. It depends on your use and the context in which you have
to apply math operations.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Apr 07 2022)
>>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>>> Python Product Development ...        https://consulting.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               https://www.egenix.com/company/contact/
                     https://www.malemburg.com/

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MXBELPGVMP7NSA6XT3FPEL6KWZKEJ4S3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to