[Rd] Complex numbers and negative zeroes

2025-04-26 Thread Mikael Jagan
0 and 0i are parsed as constants with 'positive zero' real and imaginary parts, whereas 0, 0i, and 00i are parsed as *calls*: 0~ ( 0 ) 0i ~ ( 0i) 00i ~ ((0), 0i) Keeping in mind R's usual arithmetic conversions and the IEEE 754 standard which defines e

[Rd] Complex numbers and negative zeroes

2025-04-26 Thread Antoine Fabri
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) # n