Re: [R] over/under flow

From: Gabor Grothendieck <>
Date: Mon 04 Jul 2005 - 06:58:33 EST

On 7/3/05, William H. Asquith <> wrote:
> I am porting some FORTRAN to R in which an Inf triggers an if(). The
> trigger is infinite on exp(lgamma(OVER)). What is the canonical R
> style of determining OVER when exp(OVER)== Inf? The code structure
> that I am
> porting is best left intact--so I need to query R somehow to the value
> of OVER that causes exp(lgamma(OVER)) to equal Inf.
> On my system,
> exp(lgamma(171)) is about first to equal Inf.
> I asked similar question a few weeks ago on exp(OVER) and got the
> answer back as log(.Machine$double.xmax). I now have the lgamma
> involved. I think that answer is what is OVER such the
> .Machine$double.xmax = lgamma(OVER),
> but I am not sure how to invert or solve for OVER

You could just test the result, e.g.

   result <- exp(lgamma(x))
   if (is.finite(result)) ... mailing list PLEASE do read the posting guide! Received on Mon Jul 04 07:02:20 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:11 EST