# MathF.Round 方法

## 重载

 将单精度浮点值舍入到指定的小数位数，并为中点值使用指定的舍入规则。Rounds a single-precision floating-point value to a specified number of fractional digits, and uses the specified rounding convention for midpoint values. 将单精度浮点值舍入到最接近的整数，并为中点值使用指定的舍入规则。Rounds a single-precision floating-point value to the nearest integer, and uses the specified rounding convention for midpoint values. 将单精度浮点值舍入到指定的小数位数，并将中点值舍入到最接近的偶数。Rounds a single-precision floating-point value to a specified number of fractional digits, and rounds midpoint values to the nearest even number. 将单精度浮点值舍入到最接近的整数值，并将中点值舍入到最接近的偶数。Rounds a single-precision floating-point value to the nearest integral value, and rounds midpoint values to the nearest even number.

## Round(Single, Int32, MidpointRounding)

``````public:
static float Round(float x, int digits, MidpointRounding mode);``````
``public static float Round (float x, int digits, MidpointRounding mode);``
``static member Round : single * int * MidpointRounding -> single``
``Public Shared Function Round (x As Single, digits As Integer, mode As MidpointRounding) As Single``

x
Single

digits
Int32

mode
MidpointRounding

#### 异常

`digits` 小于 0 或大于 6。`digits` is less than 0 or greater than 6.

`mode` 不是 MidpointRounding 的一个有效值。`mode` is not a valid value of MidpointRounding.

### 注解

`digits`参数的值的范围可以介于0到6之间。The value of the `digits` argument can range from 0 to 6. 请注意, 6 是该Single类型支持的整数和小数位数的最大值。Note that 6 is the maximum number of integral and fractional digits supported by the Single type.

## Round(Single, MidpointRounding)

``````public:
static float Round(float x, MidpointRounding mode);``````
``public static float Round (float x, MidpointRounding mode);``
``static member Round : single * MidpointRounding -> single``
``Public Shared Function Round (x As Single, mode As MidpointRounding) As Single``

x
Single

mode
MidpointRounding

#### 异常

`mode` 不是 MidpointRounding 的一个有效值。`mode` is not a valid value of MidpointRounding.

## Round(Single, Int32)

``````public:
static float Round(float x, int digits);``````
``public static float Round (float x, int digits);``
``static member Round : single * int -> single``
``Public Shared Function Round (x As Single, digits As Integer) As Single``

x
Single

digits
Int32

#### 异常

`digits` 小于 0 或大于 6。`digits` is less than 0 or greater than 6.

### 注解

`digits`参数的值的范围可以介于0到6之间。The value of the `digits` argument can range from 0 to 6. 请注意, 6 是该Single类型支持的整数和小数位数的最大值。Note that 6 is the maximum number of integral and fractional digits supported by the Single type.

## Round(Single)

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

x
Single