コード例 #1
0
        /// <summary>
        /// Compares this Number64 to another instance of the Number64 type.
        /// </summary>
        /// <param name="other">The other instance to compare to.</param>
        /// <returns>
        /// A negative number if this instance is less than the other instance.
        /// Zero if they are the same.
        /// A positive number if this instance is greater than the other instance.
        /// </returns>
        public int CompareTo(Number64 other)
        {
            int comparison;

            if (this.IsInteger && other.IsInteger)
            {
                comparison = this.longValue.Value.CompareTo(other.longValue.Value);
            }
            else if (this.IsDouble && other.IsDouble)
            {
                comparison = this.doubleValue.Value.CompareTo(other.doubleValue.Value);
            }
            else
            {
                // Convert both to doubleEx and compare
                DoubleEx first  = this.IsDouble ? this.doubleValue.Value : this.longValue.Value;
                DoubleEx second = other.IsDouble ? other.doubleValue.Value : other.longValue.Value;
                comparison = first.CompareTo(second);
            }

            return(comparison);
        }