Money type
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Thu Jan 2 19:00:21 UTC 2020
On Thursday, 2 January 2020 at 18:26:25 UTC, Ola Fosheim Grøstad
wrote:
> truncating. E.g. you can do the same calculation twice with
> round up/round down and do basic rounding. If you get the same
> result, then it is right. But easy to make mistakes... like I
> just demonstrated.. :-P
For those interested there work done on a standard for doing
exactly this (interval arithmetics) called IEEE1788:
https://en.wikipedia.org/wiki/Interval_arithmetic#IEEE_Std_1788-2015_%E2%80%93_IEEE_standard_for_interval_arithmetic
So all computations are done twice, once rounding up and once
rounding down. If the error gets too large then you can switch to
a slower algorithm. So then you can safely do base 2 floating
points using fast hardware without all the issues and fall back
on a slower base 10 software implementation where it fails.
More information about the Digitalmars-d
mailing list