As you know long double
is identical to double
in Visual Studio, unfortunately. However the intellisense feature shows a different story. For example check out the following code;
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
cout << "Size of float: " << sizeof(float) << endl
<< "Size of double: " << sizeof(double) << endl
<< "Size of long double: " << sizeof(long double) << endl;
cout << endl << setprecision(30) <<
" float: " << 125.6f << endl <<
" double: " << 125.6 << endl <<
"long double: " << 125.6L;
return 0;
}
Output is
Size of float: 4
Size of double: 8
Size of long double: 8
float: 125.59999847412109375
double: 125.599999999999994315658113919
long double: 125.599999999999994315658113919
But if you hover your mouse over 125.6L and 125.6, you see a difference in precision;
Although long double
and double
are identical in Visual Studio, what is the reason for the difference?
It appears that it's just the display that's different. The numeric section of the display seems to have a character limit and the character L
causes the numeric section to round in some cases and even truncated.