/// <summary> /// Converts all uppercase letters in a text string to lowercase. /// </summary> /// <param name="args"><para> /// The args contains 1 item: text. /// </para> /// <para> /// Text is the text you want to convert to lowercase. /// LOWER does not change characters in text that are not letters. /// </para></param> /// <returns> /// A <see cref="T:System.String" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); return(CalcConvert.ToString(args[0]).ToLower(CultureInfo.CurrentCulture)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> real coefficient of a complex number in x + yi or x + yj text format. /// </summary> /// <param name="args"><para> /// The args contains 1 item: inumber. /// </para> /// <para> /// Inumber is a complex number for which you want the real coefficient. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); return(CalcConvert.ToResult(ComplexConvert.ToComplex(args[0]).Real)); }
/// <summary> /// Returns the sum of a power series based on the formula. /// </summary> /// <param name="args"><para> /// The args contains 4 items: x, n, m, coefficients. /// </para> /// <para> /// X is the input value to the power series. /// </para> /// <para> /// N is the initial power to which you want to raise x. /// </para> /// <para> /// M is the step by which to increase n for each term in the series. /// </para> /// <para> /// Coefficients is a set of coefficients by which each successive /// power of x is multiplied. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { double num; int num2; int num3; base.CheckArgumentsLength(args); if ((!CalcConvert.TryToDouble(args[0], out num, true) || !CalcConvert.TryToInt(args[1], out num3)) || !CalcConvert.TryToInt(args[2], out num2)) { return(CalcErrors.Value); } object o = args[3]; double num4 = 0.0; for (int i = 0; i < ArrayHelper.GetLength(o, 0); i++) { double num6; if (!CalcConvert.TryToDouble(ArrayHelper.GetValue(o, i, 0), out num6, true)) { return(CalcErrors.Value); } num4 += num6 * Math.Pow(num, (double)(num3 + (i * num2))); } return(CalcConvert.ToResult(num4)); }
/// <summary> /// Returns the <see cref="T:System.Double" /> covariance of two lists of numbers. /// </summary> /// <param name="args"><para> /// The args contains 2 items: array1, array2. /// </para> /// <para> /// Array1 is the first cell range of integers. /// </para> /// <para> /// Array2 is the second cell range of integers. /// </para></param> /// <returns> /// A <see cref="T:System.Double" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { double num; double num2; base.CheckArgumentsLength(args); double num5 = 0.0; double num6 = 0.0; double num7 = 0.0; int length = ArrayHelper.GetLength(args[0], 0); if (length == 0) { return(CalcErrors.DivideByZero); } if (length != ArrayHelper.GetLength(args[1], 0)) { return(CalcErrors.NotAvailable); } int num9 = 0; if (ArrayHelper.IsArrayOrRange(args[0])) { for (int i = 0; i < length; i++) { object obj2 = ArrayHelper.GetValue(args[0], i, 0); object obj3 = ArrayHelper.GetValue(args[1], i, 0); if (CalcConvert.IsNumber(obj2) && CalcConvert.IsNumber(obj3)) { num = CalcConvert.ToDouble(obj2); num2 = CalcConvert.ToDouble(obj3); num5 += num; num6 += num2; num9++; } else { if (obj2 is CalcError) { return(obj2); } if (obj3 is CalcError) { return(obj3); } } } } else { if (!CalcConvert.TryToDouble(args[0], out num, true) || !CalcConvert.TryToDouble(args[1], out num2, true)) { return(CalcErrors.Value); } num5 += num; num6 += num2; num9++; } double num3 = num5 / ((double)num9); double num4 = num6 / ((double)num9); if (ArrayHelper.IsArrayOrRange(args[0])) { for (int j = 0; j < length; j++) { object obj4 = ArrayHelper.GetValue(args[0], j, 0); object obj5 = ArrayHelper.GetValue(args[1], j, 0); if (CalcConvert.IsNumber(obj4) && CalcConvert.IsNumber(obj5)) { num = CalcConvert.ToDouble(obj4); num2 = CalcConvert.ToDouble(obj5); num7 += (num - num3) * (num2 - num4); } else { if (obj4 is CalcError) { return(obj4); } if (obj5 is CalcError) { return(obj5); } } } } else { if (!CalcConvert.TryToDouble(args[0], out num, true) || !CalcConvert.TryToDouble(args[1], out num2, true)) { return(CalcErrors.Value); } num7 += (num - num3) * (num2 - num4); } return(CalcConvert.ToResult(num7 / ((double)num9))); }
/// <summary> /// Checks whether the value is refers to a number. /// </summary> /// <param name="args"><para> /// The args contains 1 item: value. /// </para> /// <para> /// Value is the value you want tested. Value can be a blank (empty cell), /// error, logical, text, number, or reference value, or a name referring /// to any of these, that you want to test. /// </para></param> /// <returns> /// A <see cref="T:System.Boolean" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { base.CheckArgumentsLength(args); return((bool)CalcConvert.IsNumber(args[0])); }
/// <summary> /// Returns the rank of a value in a data set as a percentage of the data set. /// </summary> /// <param name="args"><para> /// The args contains 2 - 3 items: array, x, [significance]. /// </para> /// <para> /// Array is the array or range of data with numeric values that defines relative standing. /// </para> /// <para> /// X is the value for which you want to know the rank. /// </para> /// <para> /// [Significance] is an optional value that identifies the number /// of significant digits for the returned percentage value. /// </para></param> /// <returns> /// A <see cref="T:System.Object" /> value that indicates the evaluate result. /// </returns> public override object Evaluate(object[] args) { double num; double num4; base.CheckArgumentsLength(args); object o = args[0]; if (!CalcConvert.TryToDouble(args[1], out num, true)) { return(CalcErrors.Value); } int result = 3; if (CalcHelper.ArgumentExists(args, 2) && !CalcConvert.TryToInt(args[2], out result)) { return(CalcErrors.Value); } double num3 = num; int num5 = 0; int num6 = 0; int num7 = 0; double num8 = num3; double num9 = num3; if (result < 1) { return(CalcErrors.Number); } for (int i = 0; i < ArrayHelper.GetLength(o, 0); i++) { object obj3 = ArrayHelper.GetValue(o, i, 0); if (obj3 != null) { double num11; if (!CalcConvert.TryToDouble(obj3, out num11, true)) { return(CalcErrors.Value); } if (num11 < num3) { num5++; if ((num8 == num3) || (num8 < num11)) { num8 = num11; } } else if (num11 > num3) { num6++; if ((num9 == num3) || (num9 > num11)) { num9 = num11; } } else { num7++; } } } if (((num5 + num7) == 0) || ((num6 + num7) == 0)) { return(CalcErrors.NotAvailable); } if (((num6 == 0) && (num5 == 0)) && (num7 != 0)) { return((double)1.0); } if (num7 == 1) { num4 = ((double)num5) / ((double)(num5 + num6)); } else if (num7 == 0) { double num12 = (num3 - num8) / (num9 - num8); num4 = ((num5 + num12) - 1.0) / ((num6 + num5) - 1.0); } else { num4 = (num5 + (0.5 * num7)) / ((num5 + num7) + num6); } return((double)Math.Round(num4, (result > 15) ? 15 : result)); }