在C#中,MathF.Ceiling(Single)是MathF类方法。此方法用于查找最小整数,该整数大于或等于参数列表中指定的单值或浮点值。
用法: public static float Ceiling (float x);
Here, x is the float(Single) value whose ceiling value has to be calculated.
返回类型:此方法返回最小的整数值,该值将大于或等于x。
例:
// C# program to illustrate the
// MathF.Ceiling(Single) Method
using System;
class GFG {
// Main method
static void Main()
{
// taking float values
float x1 = 33.00f;
float x2 = 99.99f;
// Calculate Ceiling values by
// Using MathF.Ceiling() method
float r1 = MathF.Ceiling(x1);
float r2 = MathF.Ceiling(x2);
// Print the original values
// and Ceiling values
Console.WriteLine("Input Value = " + x1);
Console.WriteLine("Ceiling value = " + r1);
// Print the original values
// and Ceiling values
Console.WriteLine("Input Value = " + x2);
Console.WriteLine("Ceiling value = " + r2);
}
}
输出:
Input Value = 33 Ceiling value = 33 Input Value = 99.99 Ceiling value = 100
相关用法
- C# MathF.Exp()用法及代码示例
- C# MathF.Cos()用法及代码示例
- C# MathF.Tan()用法及代码示例
- C# MathF.Abs()用法及代码示例
- C# MathF.Min()用法及代码示例
- C# MathF.Sin()用法及代码示例
- C# MathF.Pow()用法及代码示例
- C# MathF.Log()用法及代码示例
- C# MathF.Max()用法及代码示例
- C# MathF.Cbrt()用法及代码示例
- C# Char.GetTypeCode()用法及代码示例
- C# Char.GetHashCode()用法及代码示例
- C# MathF.Atan()用法及代码示例
- C# BitArray.RightShift()用法及代码示例
- C# BitArray.LeftShift()用法及代码示例
注:本文由纯净天空筛选整理自Kirti_Mangal大神的英文原创作品 MathF.Ceiling() Method in C# with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。