[CLN-list] Floating point overflow discrepancy
Michael Miller
millermj at lemoyne.edu
Mon Feb 21 07:05:17 CET 2011
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
More information about the CLN-list
mailing list