My console tells me that -0 returns 0 and that both c(1:5)[0] and c(1:5)[-0] return integer(0). Does R this mean that R has no concept of "negative zero"?
Although R does a good job of hiding it, in fact R does have a negative zero:
# R says these are the same
0 == -0
## [1] TRUE
identical(0, -0)
## [1] TRUE
# but they are not
is.neg0 <- function(x) x == 0 && sign(1/x) == -1
is.neg0(0)
## [1] FALSE
is.neg0(-0)
## [1] TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With