Keith Thompson wrote, On 03/11/07 18:00:
Well, it depends on the purpose of the calculations ... for instance
if I am doing a rough estimate of future values of various funds
flows, I do not need exact results, because I am putting in estimates
for rates of return and only expect a rough estimate as output.
However, in other areas, well:
Correct. If the tax returns are found to be incorrect that can lead to
large fines. If you submit accounts that are incorrect you can get
fined. If you sell the SW that is provably at fault in such cases then
the company could pursue you for damages.
Someone rather more well off than I am used a certain Borland
product to calculate his US taxes, some years ago. He actually
owed somewhere around five million dollars, if I remember right;
but the tax software claimed he owed a negative number.
He called their support people and directed their attention to
their guarantee of correctness, which said that, in the case of
any error on their part, they would pay the difference between what
their software computed, and what was actually owed. Fun times
ensued.
(The culprit turned out to be internal use of 32-bit integer types.
Once the correct number was computed, he had another adventure:
it turns out that one cannot write ordinary checks [or "cheques",
for those in the UK and Canada] for more than about one million
dollars at a time. In his case, it sufficed to simply send five
of them.)
... Having a 64 bit integer type available when you need it is very
useful. Having fixed point arithmetic (especially fixed decimal point
rather than binary point) would also be very useful, more useful for me
that a lot of what went in to C99 ;-).
One can always use the 64-bit integral type along with "manual"
fixed-point scaling, so that, e.g., 215256249812543 represents
$2,152,562,498,125.43 (a little over two trillion dollars, or about
what Iraq will most likely cost US taxpayers). One must still take
care to avoid rounding errors with internal calculations, though;
I note that a number of COBOL compilers allow up to 63 decimal
digits in intermediate results, to avoid problems here.