[CLN-list] Floating point overflow for cl_R ln (const cl_R& x)

Johnny Fundalewicz JohnnyFu at web.de
Sun Jan 9 18:44:04 CET 2005


Richard B. Kreckel wrote:
> Hi!
> 
> On Sat, 8 Jan 2005, Johnny Fundalewicz wrote:
> 
>>I'm getting some floating point overflow errors when using logarithmic
>>functionc l_R ln (const cl_R& x) with big Numbers ( > 20 Stellen).
>>

>>Have I done a mistake or whats the reason why I can't compute those
>>values - Is the number too large?
> 
> 
> What happens is that CLN figures that the result is going to be a float
> and converts the result to a cl_F of precision default_float_format before
> calling the function ln(cl_F).  But the exponent is too large and the
> conversion step triggers the overflow.
> 
> Just try increasing the precision and your code work.  You can easily
> check this by printing most_positive_float(default_float_format).
> 
> Regards
>   -richy.


Thanks,

that's been the solution! And it works unbelievably fast!


--------------------------------
> #include <cln/cln.h>
> 
> int main(){
> 
> cln::cl_R number_one = "41234123412341234123157311812341234124312359123412341";
> 
> cln::float_format_t precision = cln::float_format(700); // > number_one
> 
> cln::cl_R number_two = cln::ln ( cln::cl_float( number_one,precision ) );
> 
> std::cout << number_two << std::endl;
> 
> return 0;
> }
--------------------------------

std::cout<<cln::most_positive_float(cln::default_float_format)<<std::endl;

gave me something about x.xxE40 - That's been to small.


Johnny



More information about the CLN-list mailing list