【问题标题】:Can I make a float number in a C program always round up [closed]我可以在 C 程序中创建一个浮点数吗?
【发布时间】:2019-07-10 05:19:34
【问题描述】:

我可以在 C 程序中使浮点数总是向上取整

【问题讨论】:

标签: c


【解决方案1】:

您可以使用ceil() 函数。例如:

#include <stdio.h>
#include <math.h>

int main () {
   float val1 = 1.6;
   printf ("Round up to %.1lf\n", ceil(val1));
   return(0);
}

【讨论】:

  • 回答质量非常低的问题,无论是写问题还是解决问题都没有任何努力,这对任何人都没有好处,包括发帖人。
  • @KenWhite - 然而,c 的副本却很难找到,找到的第一个是目标 c:Round a float up to the next integer in objective C?。我想这样做了:C: How do I make a number always round up.
  • @dbc:可能是真的。但是无法找到 How do I write a more popular app than Instagram in Powershell 的副本并不意味着这个问题在这里有任何价值。 :-)
猜你喜欢
  • 1970-01-01
  • 2012-03-10
  • 1970-01-01
  • 1970-01-01
  • 2015-03-12
  • 2021-06-07
  • 1970-01-01
  • 2021-09-20
  • 1970-01-01
相关资源
最近更新 更多