Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-12 Thread Qiang Kou
Hi, Devin, You may misunderstand NaN. NaN is a special floating number. It doesn't equal to anything, even itself. If x is NaN, x == x will return false. Actually this is a trick to detect whether it is NaN or not. However, there is a standard way to handle it, using isnan [1]. Try the code below

Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-12 Thread Dirk Eddelbuettel
On 12 December 2014 at 10:09, Devin wrote: | ... but you can't set a mathematical operation equal to a string. I also tried: | | int test() | { | gsl_set_error_handler_off(); | if(gsl_sf_hyperg_2F1(1,1,1.1467003,1) == NAN){ | std::cout << "Error" << std::endl; | } | retur

Re: [Rcpp-devel] Rcpp catching a domain error

2014-12-12 Thread Devin
Thanks Qiang for your help When I try your code, this is the output I get in Rstudio: status = 1.#QNAN0 status = 0.310474 [1] 0 What I try to achieve is to feed this function with different input parameters and everytime the function results in "1.#QNAN0", it should return "NAN". I tried somet