I want to write doubles to a file but the string cast reduces the precision.
Edit : I don’t really cast but put the doubles in an ostringstream.
Is there another way than parsing each digit using modulo and division to write the doubles with more precision ?
Edit : My application needs to be portable
Here is my current code :
std::string arraytocsv(double v[], int size) {
std::ostringstream oss;
for (int i = 0; i < size; i++) {
oss << v[i] << ";";
}
oss << std::endl;
return oss.str();
}
I’ve had the precision() function, it works. Thanks
You can use precision function.