Add e to calculator (#9124)

* Add support for e

* Add tests for e

* Fix compiler complaints
This commit is contained in:
Pavel Zwerschke
2021-01-19 18:04:15 +01:00
committed by GitHub
parent 2311c3fc18
commit 6835855c66
2 changed files with 13 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Globalization;
using Mages.Core;
@@ -10,7 +11,14 @@ namespace Microsoft.Plugin.Calculator
{
public class CalculateEngine
{
private readonly Engine _magesEngine = new Engine();
private readonly Engine _magesEngine = new Engine(new Configuration
{
Scope = new Dictionary<string, object>
{
{ "e", Math.E }, // e is not contained in the default mages engine
},
});
public const int RoundingDigits = 10;
public CalculateResult Interpret(string input)