diff --git a/ClosedXML/Excel/CalcEngine/Functions/MathTrig.cs b/ClosedXML/Excel/CalcEngine/Functions/MathTrig.cs index b042a5e..d4fc266 100644 --- a/ClosedXML/Excel/CalcEngine/Functions/MathTrig.cs +++ b/ClosedXML/Excel/CalcEngine/Functions/MathTrig.cs @@ -215,7 +215,7 @@ private static object Int(List p) { - return (int)((double)p[0]); + return Math.Floor(p[0]); } private static object Ln(List p) diff --git a/ClosedXML_Tests/Excel/CalcEngine/MathTrigTests.cs b/ClosedXML_Tests/Excel/CalcEngine/MathTrigTests.cs index be8bb17..dd2eeef 100644 --- a/ClosedXML_Tests/Excel/CalcEngine/MathTrigTests.cs +++ b/ClosedXML_Tests/Excel/CalcEngine/MathTrigTests.cs @@ -1,5 +1,4 @@ using ClosedXML.Excel; -using ClosedXML.Excel.CalcEngine; using ClosedXML.Excel.CalcEngine.Exceptions; using NUnit.Framework; using System; @@ -12,7 +11,7 @@ public class MathTrigTests { private readonly double tolerance = 1e-10; - + [TestCase(1, 0.642092616)] [TestCase(2, -0.457657554)] [TestCase(3, -7.015252551)] @@ -24,7 +23,7 @@ [TestCase(9, -2.210845411)] [TestCase(10, 1.542351045)] [TestCase(11, -0.004425741)] - [TestCase(Math.PI*0.5, 0)] + [TestCase(Math.PI * 0.5, 0)] [TestCase(45, 0.617369624)] [TestCase(-2, 0.457657554)] [TestCase(-3, 7.015252551)] @@ -217,5 +216,14 @@ { Assert.Throws(() => XLWorkbook.EvaluateExpr("CSCH(0)")); } + + [TestCase(8.9, 8)] + [TestCase(-8.9, -9)] + public void Int(double input, double expected) + { + var actual = XLWorkbook.EvaluateExpr(string.Format(@"INT({0})", input.ToString(CultureInfo.InvariantCulture))); + Assert.AreEqual(expected, actual); + + } } }