Hi! On 02/21/2011 07:05 AM, Michael Miller wrote:
The following code (to calculate x^100000):
cl_R x="1.0L100000", y=1; for (int i=1; i<=100000; i++) y=x*y; cout<< y<< "\n"; cout<< exp(100000*ln(x))<< "\n";;
results in the output
1.00000000000000302104L10000000000 terminate called after throwing an instance of 'cln::floating_point_overflow_exception' what(): floating point overflow. Aborted
I know that these are very large numbers, but the two calculations are computing the same value. If the first doesn't overflow, then why does the second?
It is not only the final result that matters. When an intermediate result overflows an exception is thrown, too. You may wish to have a look at the code in src/float/transcendental/. -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>