【问题标题】:How to display a number of type Float64 upto one decimal place only如何仅将 Float64 类型的数字显示到小数点后一位
【发布时间】:2011-05-13 07:42:07
【问题描述】:

我有一个变量,Float64 min; 我只想将它显示到小数点后 1 位。现在,如果我使用 %f,我会得到 6 个位置。我怎样才能只获得 1 个名额?

【问题讨论】:

    标签: c numbers decimal printf


    【解决方案1】:

    用途:

    printf("%.1f", min);
    

    有关详细信息,请参阅this 等任何参考资料。

    【讨论】:

      猜你喜欢
      • 2022-12-05
      • 2011-05-27
      • 1970-01-01
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      相关资源
      最近更新 更多