On 13-11-07 6:39 PM, Filippo wrote:
Hi, I'm having strange differences between the R function prod ad the F90 function product. Processing the same vector C (see attachment). I get 2 different results: prod(C) = 1.069678e-307 testProduct(C) = 0where testProd is the following wrapping function: testProd <- function(x) { return(.Fortran('testProd', as.double(x), as.double(0), as.double(0), as.integer(length(x)))) } subroutine testProd(x, p, q, n) implicit none integer, intent (in) :: n double precision, intent (in) :: x(n) double precision, intent (out) :: p double precision, intent (out) :: q integer :: i p = product(x) q=1 do i = 1, n q = q*x(i) end do end subroutine testProd I check the lowest possible number and seems to be the same for both R and F90. Can anyone help me understanding this behaviour?
Some intermediate results may be stored with 80 bit precision in R, 64 bit precision in Fortran.
Duncan Murdoch ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

