次の方法で共有


Math.Round メソッド

指定した値に最も近い数値を返します。

オーバーロードの一覧

指定した値に最も近い整数を返します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function Round(Decimal) As Decimal

[C#] public static decimal Round(decimal);

[C++] public: static Decimal Round(Decimal);

[JScript] public static function Round(Decimal) : Decimal;

指定した値に最も近い整数を返します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function Round(Double) As Double

[C#] public static double Round(double);

[C++] public: static double Round(double);

[JScript] public static function Round(double) : double;

指定された精度の、指定値に最も近い数値を返します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function Round(Decimal, Integer) As Decimal

[C#] public static decimal Round(decimal, int);

[C++] public: static Decimal Round(Decimal, int);

[JScript] public static function Round(Decimal, int) : Decimal;

指定された精度の、指定値に最も近い数値を返します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function Round(Double, Integer) As Double

[C#] public static double Round(double, int);

[C++] public: static double Round(double, int);

[JScript] public static function Round(double, int) : double;

使用例

近似値に丸められるコード例を次に示します。

 
Math.Round(3.44, 1) 'Returns 3.4.
Math.Round(3.45, 1) 'Returns 3.4.
Math.Round(3.46, 1) 'Returns 3.5.

[C#] 
Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.

[C++] 

Math::Round(3.44, 1); //Returns 3.4.
Math::Round(3.45, 1); //Returns 3.4.
Math::Round(3.46, 1); //Returns 3.5.

[JScript] 
System.Math.Round(3.44, 1) //Returns 3.4.
System.Math.Round(3.45, 1) //Returns 3.4.
System.Math.Round(3.46, 1) //Returns 3.5.

参照

Math クラス | Math メンバ | System 名前空間