# MathF.Round 方法

## 重载

 Round(Single, Int32, MidpointRounding) 使用指定的舍入约定将单精度浮点值舍入到指定数量的小数位数。 Round(Single, MidpointRounding) 使用指定的舍入约定将单精度浮点值舍入到整数。 Round(Single) 将单精度浮点值舍入到最接近的整数值，并将中点值舍入到最接近的偶数。 Round(Single, Int32) 将单精度浮点值舍入到指定的小数位数，并将中点值舍入到最接近的偶数。

## 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

Single

#### 例外

`digits` 小于 0 或大于 6。

`mode` 不是 MidpointRounding 的一个有效值。

## 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

Single

#### 例外

`mode` 不是 MidpointRounding 的一个有效值。

## 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

Single

## 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

Single

#### 例外

`digits` 小于 0 或大于 6。