GetHashCode()对于相同的double可以产生不同的整数吗?

时间:2017-05-12 11:18:51

标签: c# hashcode gethashcode hash-code-uniqueness

我们假设我们在C#中有double值。

GetHashCode()是否可能在不同的计算机/窗口/架构上为此double返回不同的整数值?

    public unsafe override int GetHashCode() {
        double d = m_value; 
        if (d == 0) { 
            // Ensure that 0 and -0 have the same hash code
            return 0; 
        }
        long value = *(long*)(&d);
        return unchecked((int)value) ^ ((int)(value >> 32));
    }

0 个答案:

没有答案
相关问题