M
mathieu
Hi there,
I am trying to only display up to a maximum of 16 characters from a
double value. the following piece of code works fine most of the time,
except in some case:
#include <iostream>
#include <iomanip>
int main(int, char *[])
{
double data1 = 1.960000000000662;
double data2 = 0.960000000000662;
std::cout << std::dec << std::setprecision(15) << data1 <<
std::endl;
std::cout << std::dec << std::setprecision(15) << data2 <<
std::endl; // 17 char displayed
return 0;
}
Is there something equivalent to setprecision but which could handle
this case ? Or do I need to handle the "0.*" case and the case where
the value if negative ?
Thanks
I am trying to only display up to a maximum of 16 characters from a
double value. the following piece of code works fine most of the time,
except in some case:
#include <iostream>
#include <iomanip>
int main(int, char *[])
{
double data1 = 1.960000000000662;
double data2 = 0.960000000000662;
std::cout << std::dec << std::setprecision(15) << data1 <<
std::endl;
std::cout << std::dec << std::setprecision(15) << data2 <<
std::endl; // 17 char displayed
return 0;
}
Is there something equivalent to setprecision but which could handle
this case ? Or do I need to handle the "0.*" case and the case where
the value if negative ?
Thanks