Get precision of cout

后端 未结 2 1297
情话喂你
情话喂你 2021-01-14 17:33

I can set precision of cout output using

cout.precision(precision_value);

how can I get the precision value, which i

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 17:44

    The function is overloaded. Both overloads return the precision that was set before the call to the function. cout.precision() may be what you want to query it.

    To save it and set it back later:

    auto old_precision = cout.precision(temp_precision);
    // do stuff
    cout.precision(old_precision);
    

提交回复
热议问题