ReoGrid
ReoGrid copied to clipboard
ReoGrid 'LOG' function does not match Excel's 'LOG' function
Description
The LOG function (with no supplied base) is not consistent with how Excel handles the same formula/function
To Reproduce
- Write a formula with an Excel LOG function - with no base specified
- In Excel, if you use a LOG function without a base, the base is assumed to be 10
- 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