LoginSignup
4
1

More than 1 year has passed since last update.

【C++】streamにdouble値を最大精度の小数点表記で出力する設定

Last updated at Posted at 2019-01-08

いつも忘れるので備忘に。

#include <limits>
#include <iomanip>
#include <iostream>

int main()
{
    double v = 1.2345678901234567890;

    std::cout << v << std::endl;    // 1.23457

    // doubleの出力精度設定をmaxにする。
    std::cout << std::fixed;
    std::cout << std::setprecision(std::numeric_limits<double>::max_digits10);

    std::cout << v << std::endl;    // 1.23456789012345669
}
4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1