C# Math
C# 的 Math 类具有许多方法,允许您对数字执行数学运算。
Math.Max(x,y)
Math.Max(x, y)
方法可用于查找 x 和 y 中的最大值:
实例
Math.Max(5, 10);
Math.Min(x,y)
Math.Min(x, y)
方法可用于查找 x 和 y 中的最小值:
实例
Math.Min(5, 10);
Math.Sqrt(x)
Math.Sqrt(x)
方法返回 x 的平方根:
实例
Math.Sqrt(64);
Math.Abs(x)
Math.Abs(x)
方法返回 x 的绝对值(正值):
实例
Math.Abs(-4.7);
Math.Round()
Math.Round()
将数字四舍五入到最接近的整数:
实例
Math.Round(9.99);