ReoGrid icon indicating copy to clipboard operation
ReoGrid copied to clipboard

ReoGrid 'LOG' function does not match Excel's 'LOG' function

Open Snappee opened this issue 3 years ago • 0 comments

Description

The LOG function (with no supplied base) is not consistent with how Excel handles the same formula/function

To Reproduce

  1. Write a formula with an Excel LOG function - with no base specified
  2. In Excel, if you use a LOG function without a base, the base is assumed to be 10
  3. In ReoGrid, if you specify a LOG function without a base, it assumes you are using a LOG Natural or LOGN type function

Edition

Which edition of ReoGrid do you using?

  • Windows Form, .NET6.0

Environment

  • Window 10 Pro
  • C#
  • Visual Studio 2022

Fixed Code - 'Evaluator.cs'

case BuiltinFunctionNames.LOG_EN:
				//case BuiltinFunctionNames.LOG_RU:
                               #region LOG
				    // DHays:  Modified to match Excel.  If there is no BASE specified, then the default is a base of 10
					args = GetFunctionArgs(cell, funNode.Children, 1, 2);
					if (args.Length < 2)
					{
						if (args[0].type != FormulaValueType.Number)
						{
							throw new FormulaParameterMismatchException(cell);
						}
						return Math.Log10((double)args[0].value); // DHays:  Modified to match Excel
					}
					else
					{
						if (args[0].type != FormulaValueType.Number || args[1].type != FormulaValueType.Number)
						{
							throw new FormulaParameterMismatchException(cell);
						}
						return Math.Log((double)args[0].value, (double)args[1].value);
					}
                                  #endregion // LOG

Snappee avatar Apr 19 '22 15:04 Snappee