c++ - Using long double -


the following c++ program. want store long number such pi on variable trying use long double. when run program displays 3.14159 . how store full floating point number variable?

#include <iostream> using namespace std;  int main() { long double pi; pi = 3.14159265358979323846264338327950288419716939937510; cout << "pi = " << pi << endl; return 0; } 

using stream manipulators, it's easy:

#include <iostream> #include <iomanip>  int main() {      long double pi;     pi = 3.14159265358979323846264338327950288419716939937510l; // l long double literal      std::cout << "pi: " << std::setprecision(20) << pi;   } 

Comments

Popular posts from this blog

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -