示例#1
0
        // IComparable
        public int CompareTo(Double42 other)
        {
            Binary64 a = new Binary64(_value);
            Binary64 b = new Binary64(other._value);

            if (a.IsNan || b.IsNan)
            {
                throw new ArithmeticException("CompareTo cannot accept Nans.");
            }

            // Round away the insignificant bits of both.
            a = a.Round(INSIGNIFICANT_BITS);
            b = b.Round(INSIGNIFICANT_BITS);

            if (a.Bits < b.Bits)
            {
                return(-1);
            }
            else if (a.Bits > b.Bits)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
示例#2
0
        public override int GetHashCode()
        {
            Binary64 a = new Binary64(_value);

            // Round away the insignificant bits.
            a = a.Round(INSIGNIFICANT_BITS);
            return(a.GetHashCode());
        }
示例#3
0
        // IEquatable
        public bool Equals(Double42 other)
        {
            Binary64 a = new Binary64(_value);
            Binary64 b = new Binary64(other._value);

            if (a.IsNan || b.IsNan)
            {
                return(false);
            }

            // Round away the insignificant bits of both.
            a = a.Round(INSIGNIFICANT_BITS);
            b = b.Round(INSIGNIFICANT_BITS);

            return(a.Bits == b.Bits);
        }
示例#4
0
        public Double42 PreviousRepresentableValue()
        {
            Binary64 a = new Binary64(_value);

            return(a.PreviousRepresentableValue(INSIGNIFICANT_BITS).Value);
        }