Change default float print format

后端 未结 7 563
无人共我
无人共我 2020-12-01 16:44

I\'ve some lists and more complex structures containing floats. When printing them, I see the floats with a lot of decimal digits, but when printing, I don\'t need all of th

7条回答
  •  甜味超标
    2020-12-01 16:52

    If you are using C language, you can either use #define or "%*.*f" to do that, e.g.

    printf("%*.*f",4,2,variable);
    

提交回复
热议问题