Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RemoveBackwardsCompatibility/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/FormulaParsing/Excel/Functions/Information/IsEven.cs @ 18242

Last change on this file since 18242 was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 856 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using OfficeOpenXml.FormulaParsing.ExpressionGraph;
6using OfficeOpenXml.Utils;
7
8namespace OfficeOpenXml.FormulaParsing.Excel.Functions.Information
9{
10    public class IsEven : ExcelFunction
11    {
12        public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
13        {
14            ValidateArguments(arguments, 1);
15            var arg1 = GetFirstValue(arguments);//arguments.ElementAt(0);
16            if (!ConvertUtil.IsNumeric(arg1))
17            {
18                ThrowExcelErrorValueException(eErrorType.Value);
19            }
20            var number = (int)System.Math.Floor(ConvertUtil.GetValueDouble(arg1));
21            return CreateResult(number % 2 == 0, DataType.Boolean);
22        }
23    }
24}
Note: See TracBrowser for help on using the repository browser.