/// <summary>
 ///     Perform an add on two expression values. a+b
 /// </summary>
 /// <param name="a">The first argument.</param>
 /// <param name="b">The second argument.</param>
 /// <returns>
 ///     The result of adding two numbers. Concat for strings. If one is a
 ///     string, the other is converted to string. If no string, then if
 ///     one is float, both are converted to int.
 /// </returns>
 public static ExpressionValue Add(ExpressionValue a,
                                   ExpressionValue b)
 {
     if (a.IsString || b.IsString)
     {
         return new ExpressionValue(a.ToStringValue() + b.ToStringValue());
     }
     if (a.IsInt && b.IsInt)
     {
         return new ExpressionValue(a.ToIntValue() + b.ToIntValue());
     }
     return new ExpressionValue(a.ToFloatValue() + b.ToFloatValue());
 }
예제 #2
0
 /// <summary>
 ///     Perform an add on two expression values. a+b
 /// </summary>
 /// <param name="a">The first argument.</param>
 /// <param name="b">The second argument.</param>
 /// <returns>
 ///     The result of adding two numbers. Concat for strings. If one is a
 ///     string, the other is converted to string. If no string, then if
 ///     one is float, both are converted to int.
 /// </returns>
 public static ExpressionValue Add(ExpressionValue a,
                                   ExpressionValue b)
 {
     if (a.IsString || b.IsString)
     {
         return(new ExpressionValue(a.ToStringValue() + b.ToStringValue()));
     }
     if (a.IsInt && b.IsInt)
     {
         return(new ExpressionValue(a.ToIntValue() + b.ToIntValue()));
     }
     return(new ExpressionValue(a.ToFloatValue() + b.ToFloatValue()));
 }
예제 #3
0
        /// <summary>
        ///     Perform an equal on two expressions. Booleans, ints and strings must
        ///     exactly equal. Floating point must be equal within the default Encog
        ///     tolerance.
        /// </summary>
        /// <param name="a">The first parameter to check.</param>
        /// <param name="b">The second parameter to check.</param>
        /// <returns>True/false.</returns>
        public static ExpressionValue Equ(ExpressionValue a,
                                          ExpressionValue b)
        {
            if (a.ExprType == EPLValueType.BooleanType)
            {
                return(new ExpressionValue(a.ToBooleanValue() == b.ToBooleanValue()));
            }
            if (a.ExprType == EPLValueType.EnumType)
            {
                return(new ExpressionValue(a.ToIntValue() == b.ToIntValue() &&
                                           a.EnumType == b.EnumType));
            }
            if (a.ExprType == EPLValueType.StringType)
            {
                return(new ExpressionValue(a.ToStringValue().Equals(
                                               b.ToStringValue())));
            }
            var diff = Math.Abs(a.ToFloatValue() - b.ToFloatValue());

            return(new ExpressionValue(diff < EncogFramework.DefaultDoubleEqual));
        }
 /// <summary>
 ///     Perform a non-equal on two expressions. Booleans, ints and strings must
 ///     exactly non-equal. Floating point must be non-equal within the default
 ///     Encog tolerance.
 /// </summary>
 /// <param name="a">The first parameter to check.</param>
 /// <param name="b">The second parameter to check.</param>
 /// <returns>True/false.</returns>
 public static ExpressionValue Notequ(ExpressionValue a,
                                      ExpressionValue b)
 {
     if (a.ExprType == EPLValueType.BooleanType)
     {
         return new ExpressionValue(a.ToBooleanValue() != b.ToBooleanValue());
     }
     if (a.ExprType == EPLValueType.EnumType)
     {
         return new ExpressionValue(a.ToIntValue() != b.ToIntValue()
                                    && a.EnumType == b.EnumType);
     }
     if (a.ExprType == EPLValueType.StringType)
     {
         return new ExpressionValue(!a.ToStringValue().Equals(
             b.ToStringValue()));
     }
     double diff = Math.Abs(a.ToFloatValue() - b.ToFloatValue());
     return new ExpressionValue(diff > EncogFramework.DefaultDoubleEqual);
 }