![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I print a double value with full precision using cout in C++?
The output stream cout allows using manipulators that you can use to set the precision directly on cout and use the fixed format specifier. To get the full precision of a double, you can use the limits library. For example,
Example
#include<iostream> #include <limits> using namespace std; int main() { // Get numeric limits of double typedef std::numeric_limits< double > dbl; double PI = 3.14159265358979; cout.precision(dbl::max_digits10); cout << "Pi: " << fixed << PI << endl; return 0; }
Output
This will give the output −
3.14159265358979
Advertisements