No, but you can do two ways:
Using c
If you want the exact functionality of a function nextafter(), you can write a C function that acts as an interface to the function, so the following two restrictions are true:
:
R CMD SHLIB foo.c
UNIX- . dyn.load("foo.so"). R, .C()
.C("foo", ...)
C R .
R
number + .Machine$double.eps - , , if x - y < .Machine$double.eps if x == y. :
nextafter <- function(x, y){
delta = y - x
if(x > 0){
factor = 2^floor(log2(x)) + ifelse(x >= 4, 1, 0)
} else if (x < 0) {
factor = 65
}
if (delta > .Machine$double.eps){
return(x + factor * .Machine$double.eps)
} else if (delta < .Machine$double.eps){
return(x - factor * .Machine$double.eps)
} else {
return(x)
}
}
, C, , , .
UPDATE
, , , 2. , .Machine$double.eps, , . 2 . , :
n <- -100
factor <- vector('numeric', 100)
for(i in 1:n){
j = 0
while(TRUE){
j = j + 1
if(i - j * .Machine$double.eps != i) break()
}
factor[i] = j
}