[ Program ]/C#
[c#] 현재값과 가장 작으면서 근접하는 5의 배수 가져오기
관이119
2022. 11. 11. 09:22
반응형
int tempint = 27;
double result = 0;
if (tempint % 5 != 0)
{
result = Math.Floor(double.Parse(tempint.ToString()) / 5) * 5;
}
MessageBox.Show(result.ToString());
5로나눠서 소수점을 버리고 다시 5를 곱하면된다.
반응형