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); }
public RealValue(RationalValue value) { if (value == null) { throw new ArgumentNullException("value"); } _dataValue = (double)value.NumeratorValue / (double)value.DenominatorValue; }
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); } }
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); } }
public static ComplexValue ConvertFrom(RationalValue value) { return(new ComplexValue(value)); }
public bool Equals(RationalValue other) { return(other != null && _dataValue.IsReal && _dataValue.Real == other.ToDouble()); }
public ComplexValue(RationalValue realValue) { _dataValue.Real = realValue.ToDouble(); }
public static RealValue ConvertFrom(RationalValue value) { return(new RealValue(value)); }