Dear r-devel, In R `sign(0)` and `sign(-0)` both return `0` but negative zeroes do exist in the sense that dividing by them gives `-Inf` Complex numbers behave oddly with negative 0s, see below:
``` r 1 / Re(0 + 0i) #> [1] Inf 1 / Im(0 + 0i) #> [1] Inf 1 / Re(0 - 0i) #> [1] Inf 1 / Im(0 - 0i) # negating the imaginary part alone does nothing #> [1] Inf 1 / Re(-0 + 0i) # negating the real part alone does nothing #> [1] Inf 1 / Im(-0 + 0i) #> [1] Inf 1 / Re(-0 - 0i) # negating both parts works on the real part #> [1] -Inf 1 / Im(-0 - 0i) # but not on the imaginary part #> [1] Inf 1 / Im(0i) #> [1] Inf 1 / Re(0i) #> [1] Inf 1 / Re(-0i) # negating the imaginary part without explicitly providing the real part negates the real part #> [1] -Inf 1 / Im(-0i) # and the imaginary part too #> [1] -Inf ``` r Defined with `complex()` it seems to work ok ``` r 1 / Re(complex(real = 0, imaginary = 0)) #> [1] Inf 1 / Im(complex(real = 0, imaginary = 0)) #> [1] Inf 1 / Re(complex(real = -0, imaginary = 0)) #> [1] -Inf 1 / Im(complex(real = -0, imaginary = 0)) #> [1] Inf 1 / Re(complex(real = 0, imaginary = -0)) #> [1] Inf 1 / Im(complex(real = 0, imaginary = -0)) #> [1] -Inf 1 / Re(complex(real = -0, imaginary = -0)) #> [1] -Inf 1 / Im(complex(real = -0, imaginary = -0)) #> [1] -Inf ``` Thanks, Antoine [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel