M
mathieu
Hi there,
I am trying to find a solution for the following problem: how do I
print in ASCII a double value in a fixed size buffer of 16 bytes ?
My first attempt was:
double data = 0.960000000000662;
std::cout << std::dec << std::setprecision(15) << data << std::endl;
Because it does not work for number matching "0.[0]*", I was
suggested:
std::cout << std::dec << std::setprecision(15) << std::fixed << data
<< std::endl;
This still does not work for:
double data = 1000000.960000000000662;
and std::fixed is actually loosing all the precision for number such
as:
double data = 0.0000000000009654321;
Could someone please let me know how I can use the iomanip functions
to solve my issue ? Requirements are:
- Up to a maximum of 16 bytes
- Only [0-9], 'e'/'E', '+'/'-' and '.' character can be used
- Minimize loss of information/precision
Thanks for your time,
-Mathieu
I am trying to find a solution for the following problem: how do I
print in ASCII a double value in a fixed size buffer of 16 bytes ?
My first attempt was:
double data = 0.960000000000662;
std::cout << std::dec << std::setprecision(15) << data << std::endl;
Because it does not work for number matching "0.[0]*", I was
suggested:
std::cout << std::dec << std::setprecision(15) << std::fixed << data
<< std::endl;
This still does not work for:
double data = 1000000.960000000000662;
and std::fixed is actually loosing all the precision for number such
as:
double data = 0.0000000000009654321;
Could someone please let me know how I can use the iomanip functions
to solve my issue ? Requirements are:
- Up to a maximum of 16 bytes
- Only [0-9], 'e'/'E', '+'/'-' and '.' character can be used
- Minimize loss of information/precision
Thanks for your time,
-Mathieu