Double - Ceiling
Returns the smallest integral value that is greater than or equal to the specified double-precision floating point number.
public static void Main() { double[] values = { 7.03, 7.64, 0.12, -0.12, -7.1, -7.6 }; Console.WriteLine(" Value Ceiling\n"); foreach (double value in values) { // C# Extension Method: Double - Ceiling Console.WriteLine("{0,7} {1,16}", value, value.Ceiling()); } }
View Source
using System; public static partial class Extensions { /// <summary> /// Returns the smallest integral value that is greater than or equal to the specified double-precision floating- /// point number. /// </summary> /// <param name="a">A double-precision floating-point number.</param> /// <returns> /// The smallest integral value that is greater than or equal to . If is equal to , , or , that value is /// returned. Note that this method returns a instead of an integral type. /// </returns> public static Double Ceiling(this Double a) { return Math.Ceiling(a); } }