I expected log1p(x)
and log(x+1)
to return the same result, but they are different by 2.775558e-17. Why don't these two functions return identical results? Is one more accurate than the other?
> y <- log({32/123}+1)
> y
#> [1] 0.2312408
> x <- log1p(32/123)
> x
#> [1] 0.2312408
> x==y
#> [1] FALSE
> y-x
#> [1] 2.775558e-17
> sprintf("%a", y-x)
#> [1] "0x1p-55"