예제 #1
0
        public override bool Equals(IValueStructure other)
        {
            IntegerValue integerValue = other as IntegerValue;

            if (integerValue != null)
            {
                return(Equals(integerValue));
            }

            RationalValue rationalValue = other as RationalValue;

            if (rationalValue != null)
            {
                return(rationalValue.Equals(this));
            }

            RealValue realValue = other as RealValue;

            if (realValue != null)
            {
                return(realValue.Equals(this));
            }

            return(other == this);
        }
예제 #2
0
        public RealValue(RationalValue value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            _dataValue = (double)value.NumeratorValue / (double)value.DenominatorValue;
        }
예제 #3
0
 protected override void Action(bool isInit, Signal origin)
 {
     if (Inputs.Length == 0)
     {
         PublishToOutputs(RationalValue.MultiplicativeIdentity);
     }
     else
     {
         RationalValue product = new RationalValue((IntegerValue)Inputs[0].Value);
         for (int i = 1; i < Inputs.Length; i++)
         {
             IntegerValue integer = (IntegerValue)Inputs[i].Value;
             product = product.Divide(integer);
         }
         PublishToOutputs(product);
     }
 }
예제 #4
0
 protected override void Action(bool isInit, Signal origin)
 {
     if (Inputs.Length == 0)
     {
         PublishToOutputs(RationalValue.AdditiveIdentity);
     }
     else
     {
         RationalValue sum = ConvertFrom(Inputs[0].Value);
         for (int i = 1; i < Inputs.Length; i++)
         {
             RationalValue integer = ConvertFrom(Inputs[i].Value);
             sum = sum.Subtract(integer);
         }
         PublishToOutputs(sum);
     }
 }
예제 #5
0
 public static ComplexValue ConvertFrom(RationalValue value)
 {
     return(new ComplexValue(value));
 }
예제 #6
0
 public bool Equals(RationalValue other)
 {
     return(other != null && _dataValue.IsReal && _dataValue.Real == other.ToDouble());
 }
예제 #7
0
 public ComplexValue(RationalValue realValue)
 {
     _dataValue.Real = realValue.ToDouble();
 }
예제 #8
0
 public static RealValue ConvertFrom(RationalValue value)
 {
     return(new RealValue(value));
 }