A little problem

I made a calculating program, in which I used several variables to store specific numbers as the codes shown below. But when the program executes to the point "cout<<G<<endl;", the result came out as "0". The same goes for all the following ""cout<<...<<endl;". How do I make the program show the true number stored in those variables?

#include<iostream>
using namespace std;
int main(){


int byte = 8;

int K = byte * 1024;


cout<<K<<endl;

int M = K * 1024;

cout<<M<<endl;

int G = M * 1024;

cout<<G<<endl;

int MemoryClock = 1375 *byte*1024*1024*1024;

cout<<MemoryClock<<endl;

int MemorySpeed = G * 176;

cout<<MemorySpeed<<endl;


system("pause");
return 0;
}
It does print the "true" number, however the calculation overflows.
A 32 bit signed integer can only hold numbers up to 2^31-1 ~ 2.1 billion. Use a larger type (uint64_t) or double (at the cost of accuracy).
Topic archived. No new replies allowed.