Skip to content
Prev 16390 / 63424 Next

1/tan(-0) != 1/tan(0)

On 6/1/05, Simon Urbanek <simon.urbanek@r-project.org> wrote:
On my XP machine running R 2.1.0 patched 2005-05-14
[1] "0.000000"

does not print the sign.

however, the tan trick can be done without tan using just division:

R> sign0 <- function(x) if (x != 0) stop("x not zero") else sign(1/x)
R> sign0(0)
[1] 1
R> sign0(-0)
[1] -1