Get precision of cout

后端 未结 2 1298
情话喂你
情话喂你 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);
    
    0 讨论(0)
  • 2021-01-14 18:05

    With the function precision().

    int main() {
      std::cout << std::cout.precision() << std::endl;
      return 0;
    }
    
    0 讨论(0)
提交回复
热议问题