public void TestCeiling() { double d = 0; double s = 0; d = 0; s = 0; AssertEqual("ceiling ", 0, MathX.Ceiling(d, s)); d = 1; s = 0; AssertEqual("ceiling ", 0, MathX.Ceiling(d, s)); d = 0; s = 1; AssertEqual("ceiling ", 0, MathX.Ceiling(d, s)); d = -1; s = 0; AssertEqual("ceiling ", 0, MathX.Ceiling(d, s)); d = 0; s = -1; AssertEqual("ceiling ", 0, MathX.Ceiling(d, s)); d = 10; s = 1.11; AssertEqual("ceiling ", 11.1, MathX.Ceiling(d, s)); d = 11.12333; s = 0.03499; AssertEqual("ceiling ", 11.12682, MathX.Ceiling(d, s)); d = -11.12333; s = 0.03499; AssertEqual("ceiling ", Double.NaN, MathX.Ceiling(d, s)); d = 11.12333; s = -0.03499; AssertEqual("ceiling ", Double.NaN, MathX.Ceiling(d, s)); d = -11.12333; s = -0.03499; AssertEqual("ceiling ", -11.12682, MathX.Ceiling(d, s)); d = 100; s = 0.001; AssertEqual("ceiling ", 100, MathX.Ceiling(d, s)); d = -0.001; s = -9.99; AssertEqual("ceiling ", -9.99, MathX.Ceiling(d, s)); d = 4.42; s = 0.05; AssertEqual("ceiling ", 4.45, MathX.Ceiling(d, s)); d = 0.05; s = 4.42; AssertEqual("ceiling ", 4.42, MathX.Ceiling(d, s)); d = 0.6666; s = 3.33; AssertEqual("ceiling ", 3.33, MathX.Ceiling(d, s)); d = 2d / 3; s = 3.33; AssertEqual("ceiling ", 3.33, MathX.Ceiling(d, s)); }
public override double Evaluate(double d0, double d1) { return(MathX.Ceiling(d0, d1)); }
public void TestCeiling() { double d = 0; double s = 0; d = 0; s = 0; AssertEquals("ceiling ", 0, MathX.Ceiling(d, s)); d = 1; s = 0; AssertEquals("ceiling ", 0, MathX.Ceiling(d, s)); d = 0; s = 1; AssertEquals("ceiling ", 0, MathX.Ceiling(d, s)); d = -1; s = 0; AssertEquals("ceiling ", 0, MathX.Ceiling(d, s)); d = 0; s = -1; AssertEquals("ceiling ", 0, MathX.Ceiling(d, s)); d = 10; s = 1.11; AssertEquals("ceiling ", 11.1, MathX.Ceiling(d, s)); d = 11.12333; s = 0.03499; AssertEquals("ceiling ", 11.12682, MathX.Ceiling(d, s)); d = -11.12333; s = 0.03499; AssertEquals("ceiling ", Double.NaN, MathX.Ceiling(d, s)); d = 11.12333; s = -0.03499; AssertEquals("ceiling ", Double.NaN, MathX.Ceiling(d, s)); d = -11.12333; s = -0.03499; AssertEquals("ceiling ", -11.12682, MathX.Ceiling(d, s)); d = 100; s = 0.001; AssertEquals("ceiling ", 100, MathX.Ceiling(d, s)); d = -0.001; s = -9.99; AssertEquals("ceiling ", -9.99, MathX.Ceiling(d, s)); d = 4.42; s = 0.05; AssertEquals("ceiling ", 4.45, MathX.Ceiling(d, s)); d = 0.05; s = 4.42; AssertEquals("ceiling ", 4.42, MathX.Ceiling(d, s)); d = 0.6666; s = 3.33; AssertEquals("ceiling ", 3.33, MathX.Ceiling(d, s)); d = 2d / 3; s = 3.33; AssertEquals("ceiling ", 3.33, MathX.Ceiling(d, s)); // samples from http://www.excelfunctions.net/Excel-Ceiling-Function.html // and https://support.office.com/en-us/article/CEILING-function-0a5cd7c8-0720-4f0a-bd2c-c943e510899f d = 22.25; s = 0.1; AssertEquals("ceiling ", 22.3, MathX.Ceiling(d, s)); d = 22.25; s = 0.5; AssertEquals("ceiling ", 22.5, MathX.Ceiling(d, s)); d = 22.25; s = 1; AssertEquals("ceiling ", 23, MathX.Ceiling(d, s)); d = 22.25; s = 10; AssertEquals("ceiling ", 30, MathX.Ceiling(d, s)); d = 22.25; s = 20; AssertEquals("ceiling ", 40, MathX.Ceiling(d, s)); d = -22.25; s = -0.1; AssertEquals("ceiling ", -22.3, MathX.Ceiling(d, s)); d = -22.25; s = -1; AssertEquals("ceiling ", -23, MathX.Ceiling(d, s)); d = -22.25; s = -5; AssertEquals("ceiling ", -25, MathX.Ceiling(d, s)); d = 22.25; s = 1; AssertEquals("ceiling ", 23, MathX.Ceiling(d, s)); d = 22.25; s = -1; AssertEquals("ceiling ", Double.NaN, MathX.Ceiling(d, s)); d = -22.25; s = 1; AssertEquals("ceiling ", -22, MathX.Ceiling(d, s)); // returns an error in Excel 2007 & earlier d = -22.25; s = -1; AssertEquals("ceiling ", -23, MathX.Ceiling(d, s)); // test cases for newer versions of Excel where d can be negative for d = -11.12333; s = 0.03499; AssertEquals("ceiling ", -11.09183, MathX.Ceiling(d, s)); }
public void Ceiling() { Assert.AreEqual(0, MathX.Ceiling(0, 0)); Assert.AreEqual(1, MathX.Ceiling(0.1)); Assert.AreEqual(0.1, MathX.Ceiling(0.01, 1)); }
/// <summary> /// Finds the ceiling of the specified number to the specified number of decimal places and returns it as a string. /// </summary> /// <param name="num">The number.</param> /// <param name="decimalPlaces">The decimal places.</param> /// <returns></returns> public static string CeilingString(this double num, int decimalPlaces = 0) { return(MathX.Ceiling(num, decimalPlaces).ToString("f" + decimalPlaces)); }