Complex numbers and external crate num_complex

Why the conjugate complex number of -1+0i is displayed as -1+-0i ???
This is totally irritating... the conjugate complex number of -1+0i is -1-0i

I am using external crate num_complex version 0.4
num-complex = "0.4")

and I tested the following code:

extern crate num_complex;
use num_complex::Complex;

fn main() {

let z1 = Complex::new(-1.0, 0.0);
let conjugate = z1.conj();

println!("Complex number z1: {}", z1);
println!("Conjugate: {}", conjugate);   


and I get the following output:

Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running /Users/ralf/projects/Rust/complex/target/debug/complex

Complex number z1: -1+0i
Conjugate: -1+-0i

(program exited with code: 0)
Press return to continue

Last I heard, +0i, -0i, and +-0i were equal, both symbolically and numerically.


Just submit a PR to num_complex if you want it changed. Probably nobody has even thought about this edge case and there’s simply code that does if < 0.0 { "-" } else { "+" } or something similar.

However, negative zero is semantically distinct from positive zero in the presence of rounding: it indicates that the value before rounding to zero was negative.

Yes, and 1/0 is Inf but 1/-0 is -Inf even though 0 == -0. I don't envy the implementers of IEEE-754.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.