コード例 #1
0
ファイル: REAL.cs プロジェクト: zekiguven/cdaapi_everest_CDA
        ///// <summary>
        ///// Divides <paramref name="a"/> to <paramref name="b"/>
        ///// </summary>
        //public static REAL operator /(REAL a, INT b)
        //{
        //    if (a == null || a.IsNull || b == null || b.IsNull)
        //        return new REAL() { NullFlavor = new CS<NullFlavor>(DataTypes.NullFlavor.NoInformation) };
        //    else if (b == 0)
        //        return new REAL() { NullFlavor = DataTypes.NullFlavor.NoInformation };
        //    else if (a.Value.HasValue && b.Value.HasValue)
        //        return new REAL((double)a.Value.Value / (double)b.Value.Value);
        //    else
        //        return new REAL() { NullFlavor = new CS<NullFlavor>(DataTypes.NullFlavor.Other) };

        //}

        ///// <summary>
        ///// Multiplies <paramref name="a"/> to <paramref name="b"/>
        ///// </summary>
        //public static REAL operator *(REAL a, INT b)
        //{
        //    if (a == null || a.IsNull || b == null || b.IsNull)
        //        return new REAL() { NullFlavor = new CS<NullFlavor>(DataTypes.NullFlavor.NoInformation) };
        //    else if (a.Value.HasValue && b.Value.HasValue)
        //        return new REAL((double)a.Value.Value * (double)b.Value.Value);
        //    else
        //        return new REAL() { NullFlavor = new CS<NullFlavor>(DataTypes.NullFlavor.Other) };

        //}


        #endregion

        #region IComparable<REAL> Members

        /// <summary>
        /// Compares this REAL instance to another
        /// </summary>
        public int CompareTo(REAL other)
        {
            if (other == null || other.IsNull)
            {
                return(1);
            }
            else if (this.IsNull && !other.IsNull)
            {
                return(-1);
            }
            else if (this.Value.HasValue && !other.Value.HasValue)
            {
                return(1);
            }
            else if (other.Value.HasValue && !this.Value.HasValue)
            {
                return(-1);
            }
            else if (!other.Value.HasValue && !this.Value.HasValue)
            {
                return(0);
            }
            else
            {
                return(this.Value.Value.CompareTo(other.Value.Value));
            }
        }
コード例 #2
0
ファイル: REAL.cs プロジェクト: zekiguven/cdaapi_everest_CDA
        /// <summary>
        /// Determine if this REAL equals another REAL
        /// </summary>
        public bool Equals(REAL other)
        {
            bool result = false;

            if (other != null)
            {
                result = base.Equals((QTY <Nullable <Double> >)other) &&
                         (other.Precision == 0 ? this.Precision : other.Precision) == (this.Precision == 0 ? other.Precision : this.Precision); // NB: 0 means nothing is stated about precision so it can be equivalent
            }
            return(result);
        }
コード例 #3
0
ファイル: REAL.cs プロジェクト: zekiguven/cdaapi_everest_CDA
 /// <summary>
 /// REturns the minimum of the two REAL numbers
 /// </summary>
 public REAL Min(REAL other)
 {
     if (other == null || other.IsNull)
     {
         return(this.Clone() as REAL);
     }
     else if (this.IsNull)
     {
         return(other.Clone() as REAL);
     }
     else if (other < this)
     {
         return(new REAL((int)other));
     }
     else
     {
         return(new REAL((int)this));
     }
 }
コード例 #4
0
ファイル: REAL.cs プロジェクト: zekiguven/cdaapi_everest_CDA
        public override BL SemanticEquals(IAny other)
        {
            var baseEq = base.SemanticEquals(other);

            if (!(bool)baseEq)
            {
                return(baseEq);
            }

            // Null-flavored
            if (this.IsNull && other.IsNull)
            {
                return(true);
            }
            else if (this.IsNull ^ other.IsNull)
            {
                return(false);
            }

            // Values are equal?
            REAL realOther = other as REAL;

            if (realOther == null)
            {
                return(false);
            }
            else if (realOther.Value.HasValue && this.Value.HasValue && Math.Abs(realOther.Value.Value - this.Value.Value) <= Math.Abs(realOther.Value.Value * this.p_floatingPointEqualityTolerance))
            {
                return(true);
            }
            else if (realOther.UncertainRange != null && !realOther.UncertainRange.IsNull &&
                     this.UncertainRange != null && !this.UncertainRange.IsNull)
            {
                return(realOther.UncertainRange.SemanticEquals(this.UncertainRange));
            }
            return(false);
        }