Sujet : Re: evolution of arithmetic, was bytes, The joy of FORTRAN
De : johnl (at) *nospam* taugh.com (John Levine)
Groupes : alt.folklore.computers comp.os.linux.miscDate : 05. Mar 2025, 04:00:44
Autres entêtes
Organisation : Taughannock Networks
Message-ID : <vq8eos$1ga7$1@gal.iecc.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
It appears that Pancho <
Pancho.Jones@protonmail.com> said:
On 3/3/25 03:05, John Levine wrote:
>
That required simulating decimal
rounding with binary arithmetic, which was quite painful. If DFP makes it
easier to get correct rounding on zillion dollar financial calculations it
could well be worth the cost.
>
Why? Double precision gives you 15 digits.
It's not just having enough precision, it's getting the decimal rounding to do
the right thing with whatever number of digits the spec says. Sometimes it's
pennies, two digits after the decimal point, but sometimes it's something like
the the nearest 1/100 of a percent which would be four digits after the decimal
point.
For financial calculations, the right answer often isn't the mathematically most
accurate one, it's the one that agrees with the result that all the other people
doing financial calculations get. In some cases like bond pricing the formulas
date back to the 1920s or 1930s and were designed to be tractable with pencil
and paper or a mechanical desk calculator. They often have strange
simplifications like pretending every month has 30 days and the year has 360
days. They're defined in terms of decimal arithmetic, which is why DFP, which
unlike BFP lets you say how many digits you want to keep, is useful.
-- Regards,John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",Please consider the environment before reading this e-mail. https://jl.ly