|
1 | 1 | /******************************************************************************************************
|
2 | 2 | Title : ExpressionEvaluator (https://github.com/codingseb/ExpressionEvaluator)
|
3 |
| - Version : 1.3.4.1 |
| 3 | + Version : 1.3.4.2 |
4 | 4 | (if last digit (the forth) is not a zero, the version is an intermediate version and can be unstable)
|
5 | 5 |
|
6 | 6 | Author : Coding Seb
|
@@ -527,6 +527,13 @@ private StringComparer StringComparerForCasing
|
527 | 527 | }
|
528 | 528 | }
|
529 | 529 |
|
| 530 | + /// <summary> |
| 531 | + /// If <c>true</c> all numbers evaluations will be done as double without suffixes |
| 532 | + /// If <c>false</c> Integers values without suffixes will be evaluate as real int as in C# (Warning some operation can round values) |
| 533 | + /// By default = false |
| 534 | + /// </summary> |
| 535 | + public bool OptionForceIntegerNumbersEvaluationsAsDoubleByDefault { get; set; } = false; |
| 536 | + |
530 | 537 | private CultureInfo cultureInfoForNumberParsing = CultureInfo.InvariantCulture.Clone() as CultureInfo;
|
531 | 538 |
|
532 | 539 | /// <summary>
|
@@ -625,21 +632,12 @@ public string OptionNumberParsingThousandSeparator
|
625 | 632 | /// </summary>
|
626 | 633 | public bool OptionFluidPrefixingActive { get; set; } = true;
|
627 | 634 |
|
628 |
| - private bool optionInlineNamespacesEvaluationActive = true; |
629 |
| - |
630 | 635 | /// <summary>
|
631 | 636 | /// if <c>true</c> allow the use of inline namespace (Can be slow, and is less secure).
|
632 | 637 | /// if <c>false</c> unactive inline namespace (only namespaces in Namespaces list are available).
|
633 | 638 | /// By default : true
|
634 | 639 | /// </summary>
|
635 |
| - public bool OptionInlineNamespacesEvaluationActive |
636 |
| - { |
637 |
| - get { return optionInlineNamespacesEvaluationActive; } |
638 |
| - set |
639 |
| - { |
640 |
| - optionInlineNamespacesEvaluationActive = value; |
641 |
| - } |
642 |
| - } |
| 640 | + public bool OptionInlineNamespacesEvaluationActive { get; set; } = true; |
643 | 641 |
|
644 | 642 | private Func<ExpressionEvaluator, List<string>, object> newMethodMem;
|
645 | 643 |
|
@@ -1514,12 +1512,13 @@ private bool EvaluateNumber(string restOfExpression, Stack<object> stack, ref in
|
1514 | 1512 | }
|
1515 | 1513 | else
|
1516 | 1514 | {
|
1517 |
| - if (numberMatch.Groups["hasdecimal"].Success) |
| 1515 | + if (OptionForceIntegerNumbersEvaluationsAsDoubleByDefault || numberMatch.Groups["hasdecimal"].Success) |
1518 | 1516 | {
|
1519 | 1517 | stack.Push(double.Parse(numberMatch.Value.Replace("_",""), NumberStyles.Any, CultureInfoForNumberParsing));
|
1520 | 1518 | }
|
1521 | 1519 | else
|
1522 | 1520 | {
|
| 1521 | + |
1523 | 1522 | stack.Push(int.Parse(numberMatch.Value.Replace("_", ""), NumberStyles.Any, CultureInfoForNumberParsing));
|
1524 | 1523 | }
|
1525 | 1524 | }
|
|
0 commit comments