Link to home
Start Free TrialLog in
Avatar of Fippy_Darkpaw
Fippy_Darkpaw

asked on

C++ oftream decimal precision

Having trouble figuring out how to set decimal precision when writing ofstream to .txt file. When I open the text file produced by the following code the result is "0.111111" and not the full number of expected decimal places.


ofstream OF;
OF.open("file_name.txt");
 
double n = 0.1111111111111111;
OF << n << endl;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial