What precisely does the %g printf specifier mean?

前端 未结 2 729
执笔经年
执笔经年 2020-12-06 11:55

The %g specifier doesn\'t seem to behave in the way that most sources document it as behaving.

According to most sources I\'ve found, across multiple la

2条回答
  •  囚心锁ツ
    2020-12-06 12:25

    My favorite format for doubles is "%.15g". It seems to do the right thing in every case. I'm pretty sure 15 is the maximum reliable decimal precision in a double as well.

提交回复
热议问题