I was trying a small basic code on how R handles small numbers as shown below. I know that for fractions which cannot be represented internally, the computer rounds off to the near approximate value.
I tried computing (1+ex1-1) by assigning ex1 from 10-1 to 10-11 and each time I got ex1 as output which was right. But assigning ex1 from 10-12 and there on, the output seems to be wrong. For the second case, I am still wondering why the output is not same as ex1.
> ex1 <- 10^-11
> (1+ex1)-1
[1] 1e-11
> ex1 <- 10^-12
> (1+ex1)-1
[1] 1.000089e-12
I tried looking at the other stack answer but couldn't find one. This might be duplicate but I am looking for an answer or at least a hint.