[R] Problem with the mod function %%

arun smartpink111 at yahoo.com
Tue Jun 18 16:23:48 CEST 2013


Hi,
Possibly, R FAQ: 7.31
http://www.hep.by/gnu/r-patched/r-faq/R-FAQ_82.html

(1.1%%1)-0.1
#[1] 8.326673e-17

fun1 <- function(x, y, eps = .Machine$double.eps^0.5) abs(x - y) < eps
 fun1(1.1%%1,0.1)
#[1] TRUE
A.K.



0.1%%1==0.1 
returns TRUE, which is right 

But 
1.1%%1==0.1 
returns FALSE !! 

Note that 1.1%%1>0.1 returns TRUE 

Can someone explain what is wrong? 
I'm using R version 2.15.3 on a mac. 

Thank you in advance



More information about the R-help mailing list