R
Russell Shaw
Hi,
I'm using gcc-3.4.3 on a linux pc. The ints and long ints are 32 bits
and long long ints are 64 bits.
When i have:
int num=9600;
long long int reg=(long long)800000000000/(5000000*num);
the denominator overflows and gives an incorrect answer: reg=1059
With an extra cast:
long long int reg=(long long)800000000000/((long long)5000000*num);
i get: reg=16
If the numerator is a long long int, should the denominator be
automatically promoted to a long long int?
I'm using gcc-3.4.3 on a linux pc. The ints and long ints are 32 bits
and long long ints are 64 bits.
When i have:
int num=9600;
long long int reg=(long long)800000000000/(5000000*num);
the denominator overflows and gives an incorrect answer: reg=1059
With an extra cast:
long long int reg=(long long)800000000000/((long long)5000000*num);
i get: reg=16
If the numerator is a long long int, should the denominator be
automatically promoted to a long long int?