Is there a function to round a float in C or do I need to write my own?

后端 未结 7 1418
旧时难觅i
旧时难觅i 2020-11-27 07:02

Is there a function to round a float in C or do I need to write my own?

float conver = 45.592346543;

I would

7条回答
  •  隐瞒了意图╮
    2020-11-27 07:36

    Sure, you can use roundf(). If you want to round to one decimal, then you could do something like: roundf(10 * x) / 10

提交回复
热议问题