I have a file.txt with hundreds of numbers. They have many digits (max 20) after the point and I need to get them all without truncation, otherwise they introduce errors in the following computations. I made these numbers with matlab so it has a monstrous precision but now I must replicate this behaviour in my program.
I've done this way:
fstream in;
in.open(file.txt, ios::in);
long double number;
in>>number;
I also tried this
in.precision(20);
in>>number;
before each ">>" operation but it is vain.
If I copy and paste these numbers in my code assigning them to long double variables all goes well as it were matlab. It's a problem of functions or fstream, not precision of long double type, isn't it?
For examples, take this number 2.7239385667867091 and save it in a file.txt. Can you read all its digits with C++ and fstream?