I'm trying to understand the coercion rationale for doubles:
as.logical(c(-1, -0.01, 0, 0.01, 0.1,1:10))
#> [1] TRUE TRUE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [12] TRUE TRUE TRUE TRUE
I can see that coercion happens on a scalar (sign doesn't matter) and
that only exactly 0 is coerced to FALSE
. I was surprised by this,
there seems to be no notion of "closest to..." or rounding to 0L or 1L.
I'm curious as to why.
I did try to hunt around for insight here but no success.
I also looked at this related question.
Can someone explain why I should expect each of the above tested values to coerce as they do?