gpt4 book ai didi

c++ - cout long double值时有错误答案,C++

转载 作者:搜寻专家 更新时间:2023-10-31 00:09:27 25 4
gpt4 key购买 nike

<分区>

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

using namespace std;

int main() {
const long double longDoublePI = 3.141592653589793238;
cout << setw(16) << "longDoublePI = " << setprecision(numeric_limits<long double>::digits10 + 1) << longDoublePI << endl;

return 0;
}

但是结果输出是:

longDoublePI = 3.141592653589793116

为什么答案是错误的?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com