I am trying to check memory limit for my application. I am multiplying some constant with argv[1]. I am getting correct results if my arg[1] is 5000 and incorrect value if arg[1] is 6000. Infact it is returning samller value when I multiply with 6000. my code is as follows: ====================== #include <iostream> #include <stdio.h> using namespace std;
int main(int args, char **argv) { int rowsetSize = atoi(argv[1]); const long long twoGB = 2560000000UL; //2.5 GB const unsigned int recordLength = 30046; long long totalMemory = (long long) ( 50L * rowsetSize * recordLength ) ; { cout << "total Memory: " << totalMemory << " rowset size: " << rowsetSize << " record length: " << recordLength << endl; } if ( totalMemory > twoGB ) { cout << "program memory requirement exceeds 2.5GB, try again by decreasing the transaction size." << endl; } I compiled as gcc -lstdc++ -g -o limit1.exe limit1.cpp output ======= $ ./limit1.exe 6000 total Memory: 423865408 rowset size: 6000 record length: 30046 $ ./limit1.exe 5000 total Memory: 3216532704 rowset size: 5000 record length: 30046 program memory requirement exceeds 2.5GB, try again by decreasing the transaction size. my system specification: ========================= $ uname -a Linux BMC011 2.6.9-22.0.2.ELsmp #1 SMP Thu Jan 5 17:13:01 EST 2006 i686 i686 i386 GNU/Linux thank nirmala -- Summary: wrong results - when long long varaible is multiplied with big number Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jvn245 at yahoo dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30603