MathF.Truncate(Single) 方法

定义

计算指定单精度浮点数的整数部分。Calculates the integral part of a specified single-precision floating-point number.

public:
 static float Truncate(float x);
public static float Truncate (float x);
static member Truncate : single -> single
Public Shared Function Truncate (x As Single) As Single

参数

x
Single

要截断的数字。A number to truncate.

返回

x 的整数部分(即舍弃小数位后剩余的数或下表所列出的值之一)。The integral part of x; that is, the number that remains after any fractional digits have been discarded, or one of the values listed in the following table.

x 返回值Return value
NaNNaN
NegativeInfinityNegativeInfinity
PositiveInfinityPositiveInfinity

注解

Truncatex零舍入到最接近的整数。Truncate rounds x to the nearest integer towards zero.

适用于

另请参阅