📌  相关文章
📜  将数字四舍五入到最接近的奇数值 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:42.485000             🧑  作者: Mango

代码示例1
//rounds a number to the closest odd value
// sudo code----------------------------------------
x = 2 * floor (x/2) + 1
//for example 2.1 -> 3 ,  3.9 -> 3 , 4.1 -> 5 etc...

//C#------------------------------------------------
Using System;

double x = 2.1;
x = 2 * Math.Floor(x/2) + 1; // x is now 3
Console.Write(x);