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

后端 未结 7 1430
旧时难觅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:27

    #include 
    
    double round(double x);
    float roundf(float x);
    

    Don't forget to link with -lm. See also ceil(), floor() and trunc().

提交回复
热议问题