I'm a bit stumped in trying to cast a very basic int division to a long result and the irony is that I've managed to use typecasting from float to long with complex equations. I just can't seen what's wrong with this...
Code:
int main(){
int initVol = 40;
int intIndex;
long longIndex;
intIndex = initVol / 100;
printf("int index = %d, ");
longIndex = (long) ( initVol / 100 );
printf("long index = %d.\n");
return 0;
}
Both intIndex and longIndex give the wrong answer. But why? I would have expected intIndex to be correct at the very least.