21 Feb
2011
21 Feb
'11
7:05 a.m.
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? Mike