I have recently become interested in learning about programming in c++, because I want to get a bit deeper understanding of the way computers work and handle instructions. I thought I would try out the data types, but I don't really understand what's happening with my output...
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float fValue = 123.456789;
cout << setprecision(20) << fixed << fValue << endl;
cout << "Size of float: " << sizeof(float) << endl;
double dValue = 123.456789;
cout << setprecision(20) << fixed << dValue << endl;
cout << "Size of double: " << sizeof(double) << endl;
long double lValue = 123.456789;
cout << setprecision(20) << fixed << lValue << endl;
cout << "Size of long double: " << sizeof(long double) << endl;
return 0;
}
The output I expected would be something like:
123.45678710937500000000
Size of float: 4
123.45678900000000000000
Size of double: 8
123.45678900000000000000
Size of long double: 16
This is my actual output:
123.45678710937500000000
Size of float: 4
123.45678900000000000000
Size of double: 8
-6518427077408613100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00000000000000000000
Size of long double: 12
Any ideas on what happened would be much appreciated, thanks!
Edit:
System:
Windows 10 Pro Technical Preview
64-bit Operating System, x64-based processor
Eclipse CDT 8.5