Why is there no difference between double, long double or float?
For instance, the computation of pi
in C++
is,
#include <iostream>
#include <quadmath.h>
#include <math.h>
int main()
{
float PI0 = acos(-1.0);
double PI1 = acos(-1.0);
long double PI2= acos(-1.0L);
__float128 x = acos(-1.0);
char buf[128];
quadmath_snprintf (buf, sizeof buf, "%*.34Qf",10, x);
std::cout << "Float=" << PI0 << std::endl;
std::cout << "Double=" << PI1 << std::endl;
std::cout << "LongDouble=" << PI2 << std::endl;
std::cout << "Float128=" << buf << std::endl;
}
In the terminal:
g++ -std=c++14 FileName.cpp -Wall -pedantic -lquadmath && ./a.out
Output:
Float=3.14159
Double=3.14159
LongDouble=3.14159
Float128=3.1415926535897931159979634685441852
For detail: https://msdn.microsoft.com/en-us/library/cc953fe1.aspx