W dniu 2 lutego 2011 16:35 użytkownik Wacek Kusnierczyk
<waku@idi.ntnu.no>napisał:

> On 2/2/11 3:59 AM, Łukasz Ręcławowicz wrote:
>
>> We don't need a loop!
>>
>> require(Rmpfr)
>> factorial(mpfr(1:500,3800))
>>
>
> This is very good!

But it has just a few functions...

>  I get an unexpected warning, though:
>
> Warning message:
> In if (mpfr.is.integer(x)) round(r) else r :
>    the condition has length > 1 and only the first element will be used


This is strange... when you run this twice it's ok, no warning.
> str(j[500])
Formal class 'mpfr' [package "Rmpfr"] with 1 slots
..@ .Data:List of 1
.. ..$ :Formal class 'mpfr1' [package "Rmpfr"] with 4 slots
.. .. .. ..@ prec: int 4000
.. .. .. ..@ exp : int 3768
So setting 3800 bits should be enough, 4e3 bits gives no rounding warning.
You can use this factorials without any numeric problems with second loop
(but you have to wait looonger...). Changing code it's a very good idea.

-- 
Miłego dnia

	[[alternative HTML version deleted]]

