指定した値に最も近い整数を返します。
Overloads Public Shared Function Round( _
ByVal d As Decimal _) As Decimal
[C#]
public static decimal Round(decimald);
[C++]
public: static Decimal Round(Decimald);
[JScript]
public static function Round(
d : Decimal) : Decimal;
パラメータ
- d
丸め対象の Decimal 数。
戻り値
パラメータ d の近似値である整数。 d が 2 つの整数 (一方の整数が偶数でもう一方が奇数) の中間にある場合は偶数が返されます。
解説
このメソッドの動作は、IEEE 規格 754、セクション 4 に従います。このような丸めは、近似値への丸めまたは銀行の丸めと呼ばれることがあります。
使用例
近似値に丸められるコード例を次に示します。
Math.Round(4.4) 'Returns 4.0.
Math.Round(4.5) 'Returns 4.0.
Math.Round(4.6) 'Returns 5.0.
[C#]
Math.Round(4.4); //Returns 4.0.
Math.Round(4.5); //Returns 4.0.
Math.Round(4.6); //Returns 5.0.
[C++]
Math::Round(4.4); //Returns 4.0.
Math::Round(4.5); //Returns 4.0.
Math::Round(4.6); //Returns 5.0.
[JScript]
System.Math.Round(4.4) //Returns 4.0.
System.Math.Round(4.5) //Returns 4.0.
System.Math.Round(4.6) //Returns 5.0.
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard
参照
Math クラス | Math メンバ | System 名前空間 | Math.Round オーバーロードの一覧 | Ceiling | Floor