I'm trying to read a bunch of constants of a text-file in C++ using the <fstream>
library. The constants are 16 decimal places long, or 16 digits after the decimal point. Now, whenever I try to read those digits, the program truncates it to 6 decimal places whether I use the datatypes double
or long double
.
The program goes on something like this -
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
int main(){
vector<double> test;
ifstream fin;
fin.open("constants.txt");
double num;
while(fin>>num){
test.push_back(num);
}
for(int i=0; i<64; i++){
cout<<test[i]<<"\n";
}
return 0;
}
And the constants, from the constants.txt
file go on something like 0.2599210498948732
, but when I try to print it using the program, it truncates it to 0.259921
. What do i to print the entire of the 16 digit long decimal number?