Reputation: 2964
Is it reliable to compare with R_PosInf
so that for any double
number
number < R_PosInf == true
Upvotes: 1
Views: 216
Reputation: 368389
Easy enough to try!
#include <Rcpp.h>
// [[Rcpp::export]]
bool compToInf(double x) {
return x < R_PosInf;
}
/*** R
compToInf(.Machine$double.xmax) ## largest representable double
compToInf(Inf)
*/
R> sourceCpp("/tmp/so50229770.cpp")
R> compToInf(.Machine$double.xmax) ## largest representable double
[1] TRUE
R> compToInf(Inf)
[1] FALSE
R>
Upvotes: 5