Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 六角浮动机械手与精度_C++_C++11_Hex_Precision - Fatal编程技术网

C++ 六角浮动机械手与精度

C++ 六角浮动机械手与精度,c++,c++11,hex,precision,C++,C++11,Hex,Precision,为什么使用hexfloat操纵器的输出会忽略ostream上的任何精度 #include <iostream> #include <cmath> #include <iomanip> using namespace std; int main(){ cout << setw(17) << left << "default format: " << setw(20) << right &l

为什么使用
hexfloat
操纵器的输出会忽略
ostream
上的任何精度

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){

    cout << setw(17) << left << "default format: " << setw(20) << right << 100 * sqrt(2.0) << " " <<  cout.precision() << '\n'
         << setw(17) << left << "scientific: " << setw(20) << right << scientific << 100 * sqrt(2.0) << " " <<  cout.precision() <<  '\n'
         << setw(17) << left << "fixed decimal: " << fixed << setw(20) << right << 100 * sqrt(2.0) << " " <<  cout.precision() <<  '\n'
         << setw(17) << left << "hexadecimal: " << hexfloat << setw(20) << right << uppercase << 100 * sqrt(2.0) << nouppercase << " " <<  cout.precision() <<  '\n'
         << setw(17) << left << "use defaults: " << defaultfloat << setw(20) << right << 100 * sqrt(2.0) << " " <<  cout.precision() <<  "\n\n";

}

是否可以使用十六进制格式确保十进制精度为6?

标准::hexfloat格式旨在转储浮点值的精确重复。字符串表示不是供人使用的,而是主要用于再次恢复完全相同的表示。因此,基于任何流设置以任何方式截断格式是没有意义的。

请参阅。
default format:               141.421 6
scientific:              1.414214e+02 6
fixed decimal:             141.421356 6
hexadecimal:     0X1.1AD7BC01366B8P+7 6
use defaults:                 141.421 6