40/100 = 0 why?

 

I just test this one


Comment(" 40%= ", 40/100);


it show me 0, why?

 

int i = 1 / 2; // no types casting, the result is 0

double d = 1.0 / 2.0; // no types casting, the result is 0.5


Try this instead. Not sure if its the right solution, but it shows 0.4 instead of 0

Comment (" 40%= ", 40.0/100.0);
 

This is fail as well


Comment(" 40%= ", 40/100*1.0);


I expect to get 0.40, but the above give me 0 again. so the casting thing did not work in this case.


But it work if I do this

Comment(" 40%= ", 1.0*40/100);


Now, do you think it is a bug?

 

NVM, I got it, it run from left to right , step by step. Remind me the C language :)

Thanks

Reason: