C#NumberMath.Round
Math.Floor

Math.RoundNumber

Math.Max

Rounds a value to the nearest integer or specified decimal places.

문법

Math.Round(d, digits?, mode?)

예제

아래 값을 입력하면 예제에 즉시 반영됩니다.

Console
WriteLine
Math
banker
rounding
MidpointRounding
AwayFromZero
Console.WriteLine(Math.Round(4.5));         // 4 (banker's rounding)
Console.WriteLine(Math.Round(4.5, MidpointRounding.AwayFromZero));   // 5
Console.WriteLine(Math.Round(3.14159, 2));  // 3.14