I am just starting to learn how to code(like 3 days ago) And I have a few problems... First, my "int", "long int", and "unsigned int" All appear to be the same size.
#include <iostream>
#include <limits.h>
using namespace std;
int main() {
int value = 2147483647;
cout << value << endl;
cout << "Max int value: "<< INT_MAX << endl;
cout << "Min int value: "<< INT_MIN << endl;
long lvalue = 568534534;
cout << lvalue << endl;
short svalue = 22344;
cout << svalue << endl;
cout << "Size of int " << sizeof(int) << endl;
cout << "Size of short int: " << sizeof(short) << endl;
cout << "Size of long int: " << sizeof(long) << endl;
cout << "Size of unsigned int: " << sizeof(unsigned int) << endl;
unsigned int uvalue = 5345554;
cout << uvalue << endl;
return 0;
}
And when I run it, I get this:
568534534
22344
Size of int 4
Size of short int: 2
Size of long int: 4
Size of unsigned int: 4
5345554
As you can see. Long, and unsigned int = int.
This isn't my only problem. With "long double" no matter how big the number is, it ALWAYS outputs a negative. Here's the code:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float fvalue = 123.456789;
cout << sizeof(float) << endl;
cout << setprecision(20) << fixed << fvalue << endl;
double dvalue = 234.5554;
cout << setprecision(20) << fixed << dvalue << endl;
long double lvalue = 123.4;
cout << setprecision(20) << fixed << lvalue << endl;
return 0;
}
Here's the result:
4
123.45678710937500000000
234.55539999999999000000
-18137553330312606000000000000000000000000000000000000
(Removed most of the zeros btw)
So, as you can see there are problems with something. I am using eclipse as my IDLE and I use MinGW32 Though I am on a 64 bit system, I tried to install MinGW-w64 for my system but couldn't find out how...