hello,
i have made a program to try the "long integer" instead of integer for a very long number, but it has some really strange results. Is it possible to look for this problem ? Many thanks
// eventjes testen wat we nog weten van gisteren
#include <iostream>
using namespace std ;
int main (){
cout << "geef een variabele"<< endl;
string var1 ;
cin >> var1;
cout << "geef de string weer "<< var1 << endl ;
cout << "geef een integer "<< endl;
long int var2 ;
cin >> var2;
cout << "integer is "<< var2 << endl;
cout << "de hoeveelheid bytes is"<< sizeof(var2)<< endl;
return 0;
}
This came out of result :
sdgsfgs.
geef de string weer sdgsfgs.
geef een integer
5469484949864565465
integer is 2147483647
de hoeveelheid bytes is4
I don't understand why he didn't gave me this very long number to me ...
You are presumably on a 32-bit system and your compiler has chosen a size of 32 bits for longint. It could have chosen 64 bits and certainly would have on a 64-bit system. The value 2147483647 is the maximum value for a 32-bit signed int. You can try longlongint, which is guaranteed to be 64-bits.