在C#中,MathF.Floor(Single)是MathF類方法。此方法用於查找最大整數,該整數小於或等於參數列表中指定的浮點值。
用法: public static float Floor (float x);
Here, x is the float(Single) value whose floor value has to be calculated.
返回類型:此方法返回最大整數值,該值將小於或等於x。
例:
// C# program to illustrate the
// MathF.Floor(Single) Method
using System;
class GFG {
// Main method
static void Main()
{
// taking float values
float x1 = 37.00f;
float x2 = 99.99f;
float x3 = 0.2154f;
float x4 = 123.123f;
float x5 = -2.2f;
float x6 = -123.123f;
// calling the method
result(x1);
result(x2);
result(x3);
result(x4);
result(x5);
result(x6);
}
public static void result(float t1)
{
// Print the original values
// and Floor values
Console.WriteLine("Input Value = " + t1);
// using the MathF.Floor() Method
Console.WriteLine("Floor value = " + MathF.Floor(t1));
}
}
輸出:
Input Value = 37 Floor value = 37 Input Value = 99.99 Floor value = 99 Input Value = 0.2154 Floor value = 0 Input Value = 123.123 Floor value = 123 Input Value = -2.2 Floor value = -3 Input Value = -123.123 Floor value = -124
相關用法
- 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.Floor() Method in C# with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。