.NET 中的 Complex-struct 是否知道 0 有哪个符号?

Does the Complex-struct in .NET know which sign 0 has?

在python中,如果我想要一个复数1+0i,那么它会被表示为(1+0j);如果我想要共轭,它表示为(1-0j)。在 .NET 上,1+0i 表示为浮点元组 (1, 0),而 Complex 结构似乎没有显示有关 0 是否为 "negative."

的任何信息

为了解决这个问题,我一直用 Double.Epsilon 表示 0 值,因为就我而言它足够接近,并且允许我基本上有一个负零。

当我使用 Complex.Conjugate(new Complex(1, 0)) 时,.NET 是否知道表达式现在是 1-0i?

+0和-0是有区别的。他们有不同的位表示。

基于this answer我写了一个单元测试(通过):

[TestMethod]
public void ComplexZeroTest()
{
    Complex c = new Complex(1, 0);
    Complex d = Complex.Conjugate(c);
    Assert.AreEqual(c.Real, d.Real);
    Assert.AreEqual(c.Imaginary, d.Imaginary);
    Assert.AreNotEqual(BitConverter.DoubleToInt64Bits(c.Imaginary), 
                       BitConverter.DoubleToInt64Bits(d.Imaginary));
}

所以你的问题的答案似乎是肯定的。