Describe the bug
https://en.cppreference.com/w/cpp/io/manip/fixed
Notes
Hexadecimal floating-point formatting ignores the stream precision specification,
as required by the specification of std::num_put::do_put.
Command-line test case
C:\Temp>type main.cpp
#include <cstdlib>
#include <iomanip>
#include <iostream>
struct scand
{
char* pos;
double v;
scand(const char* str) : v(std::strtod(str, &pos)) {}
operator double() const { return v; }
};
// For hexfloat stream output, the stream precision should be ignored
int main()
{
std::cout << std::hexfloat;
std::cout << "default precision 6: " << scand("0x1.0123456789abcdef") << '\n';
for (int i = 0; i < 16; ++i)
std::cout << "precision set to " << std::setw(2) << i << ": "
<< std::setprecision(i) << scand("0x1.0123456789abcdef") << '\n';
}
C:\Temp>cl /EHsc /W4 /WX main.cpp
Оптимизирующий компилятор Microsoft (R) C/C++ версии 19.27.29109 для x64
(C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.
main.cpp
Microsoft (R) Incremental Linker Version 14.27.29109.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
main.obj
C:\Temp>main.exe
default precision 6: 0x1.012345p+0
precision set to 0: 0x1.012345p+0
precision set to 1: 0x1.0p+0
precision set to 2: 0x1.01p+0
precision set to 3: 0x1.012p+0
precision set to 4: 0x1.0123p+0
precision set to 5: 0x1.01234p+0
precision set to 6: 0x1.012345p+0
precision set to 7: 0x1.0123456p+0
precision set to 8: 0x1.01234567p+0
precision set to 9: 0x1.012345679p+0
precision set to 10: 0x1.012345678ap+0
precision set to 11: 0x1.0123456789bp+0
precision set to 12: 0x1.0123456789acp+0
precision set to 13: 0x1.0123456789abdp+0
precision set to 14: 0x1.0123456789abd0p+0
precision set to 15: 0x1.0123456789abd00p+0
Expected behavior
Correct output:
default precision 6: 0x1.0123456789abdp+0
precision set to 0: 0x1.0123456789abdp+0
precision set to 1: 0x1.0123456789abdp+0
precision set to 2: 0x1.0123456789abdp+0
precision set to 3: 0x1.0123456789abdp+0
precision set to 4: 0x1.0123456789abdp+0
precision set to 5: 0x1.0123456789abdp+0
precision set to 6: 0x1.0123456789abdp+0
precision set to 7: 0x1.0123456789abdp+0
precision set to 8: 0x1.0123456789abdp+0
precision set to 9: 0x1.0123456789abdp+0
precision set to 10: 0x1.0123456789abdp+0
precision set to 11: 0x1.0123456789abdp+0
precision set to 12: 0x1.0123456789abdp+0
precision set to 13: 0x1.0123456789abdp+0
precision set to 14: 0x1.0123456789abdp+0
precision set to 15: 0x1.0123456789abdp+0
STL version
Microsoft Visual Studio Community 2019 Preview Version 16.7.0 Preview 6.0
Additional context
VSO-847068 / AB#847068 | DevCom-520472
The zero-precision bug found by statementreply below is also tracked by Microsoft-internal VSO-294512 / AB#294512.
Describe the bug
https://en.cppreference.com/w/cpp/io/manip/fixed
Command-line test case
Expected behavior
Correct output:
STL version
Microsoft Visual Studio Community 2019 Preview Version 16.7.0 Preview 6.0Additional context
VSO-847068 / AB#847068 | DevCom-520472
The zero-precision bug found by statementreply below is also tracked by Microsoft-internal VSO-294512 / AB#294512.