Math.Ceiling()向上取整,Math.Floor()向下取整
示例:
d = 4.56789
string res = Math.Ceiling(Convert.ToDecimal(d)).ToString()
或string res = Math.Ceiling(Convert.ToDouble(d)).ToString();
res为5

string res = Math.Floor(Convert.ToDecimal(d)).ToString()
或string res = Math.Floor(Convert.ToDouble(d)).ToString();
res为4

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-08-17
  • 2021-12-27
相关资源
相似解决方案