Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
c# を使用して、このような値を切り上げるにはどうすればよいですか。
1.1 => 1.5 2.0 => 2.0 2.1 => 2.5 1.9 => 1.5 7.7 => 7.5
私は常に値が0.5またはにあることを望みます0.0
0.5
0.0
if(no-(int)no!=0.0) no=(int)no+0.5
double d = 1.1; if (d != Math.Floor(d)) d = Math.Floor(d) + 0.5;
これを試して、すべての値を確認してください。
それがうまくいくことを願っています!