[CLN-list] Operations with different precisions
bruno at clisp.org
Mon Oct 12 21:04:14 CEST 2009
> following code snippet
> cln::cl_F x = cl_float(0.5, cln::float_format(50));
> x = cos(x);
> cout << "\n" << x << "\n";
> x = x + cln::cl_F(1.);
> cout << x << "\n";
> gives the output
This is normal, expected, and a feature.
> Is there a feature that the float with the highest precision
> is used as the result precision?
No, as this would be a misfeature.
cln::cl_F x = cl_float(0.5, cln::float_format(50));
x = cos(x);
cout << "\n" << x << "\n";
x = x + cln::cl_F(1./3.);
cout << x << "\n";
Currently CLN gives the output
With your suggestion, it would give the output
but the correct result of cos(0.5) + 1/3 is
1) The result marked with "<===" would have way more wrong digits than
correct ones, and you have no way to know it just by looking at the
2) If you continue to do computations with that result, two third of the
computation time will be wasted with treatment of garbage digits.
In other words, your proposed result would have an accuracy that is much lower
than the precision. However, the expectation for a final result is that the
the accuracy is equal or nearly equal to the precision.
More information about the CLN-list