There are R functions that automatically take sensible approaches to the "equality problem":
> (3 - 2.9) <=0.1
#[1] FALSE
> all.equal( (3 - 2.9) , 0.1)
#[1] TRUE
It uses the sqrt of R's smallest positive floating point number as its default threshold, so it handles multiplications and division propagated errors. Ends up being around 1e-08
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…