rprecisionnumericexponentialunderflow

How to deal with underflow in R?


I want to compute this number : 0.34911191 ^ 1157 I am using R programming language and it returns me 0 (this is an underflow problem). How I can fix it? Thanks.


Solution

  • Are you looking for something like this?
    The CRAN package Brobdingnag has two vignettes explaining its use.

    library(Brobdingnag)
    
    x <- 1157 * log(0.34911191)
    y <- as.brob(x)
    exp(y)
    #[1] +exp(-1217.6)
    exp(y) < .Machine$double.neg.eps
    #[1] TRUE