C: printf a float value

后端 未结 6 1350
-上瘾入骨i
-上瘾入骨i 2020-11-28 08:36

I want to print a float value which has 2 integer digits and 6 decimal digits after the comma. If I just use printf(\"%f\", myFloat) I\'m getting a truncated va

6条回答
  •  悲哀的现实
    2020-11-28 08:55

    You can do it like this:

    printf("%.6f", myFloat);
    

    6 represents the number of digits after the decimal separator.

提交回复
热议问题