Possible Duplicate:
What is the behavior of integer division in C?
When I do a division calculation with an answer that's supposed to be between 1 and 0, it always returns 0.
Try this:
float a = 1;
float b = 2;
float c = a / b; //variable divide by variable gives 0.5 as it should
float d = 1 / 2; //number divide by number gives 0
float e = 4 / 2;
NSLog(@"%f %f %f %f %f", a,b,c, d, e);
I get this from the console:
2013-01-17 14:24:17.512 MyProject[1798:c07] 1.000000 2.000000 0.500000 0.000000 0.500000
I have no idea what is going on.