I'm running the following code:
float fSpeed = 1 + (uRate / 10);
uRate is -5.
I was hoping to get the result 0.5 because (uRate / 10) should be -0.5
However, fSpeed is 0. Does anybody see my mistake?
Thank you.
I'm running the following code:
float fSpeed = 1 + (uRate / 10);
uRate is -5.
I was hoping to get the result 0.5 because (uRate / 10) should be -0.5
However, fSpeed is 0. Does anybody see my mistake?
Thank you.
Just write
float fSpeed = 1 + (uRate / 10.0f);
In this case the expression (uRate / 10.0f)
will have a floating value due to the usual arithmetic conversions.