i'm having a problem with floats.
Code:
int a, b;
float percentage;
// ...
if (a == b)
setbar(0.5);
else {
percentage = a/(a+b);
// check here
setbar(percentage);
}
and set bar is defined like this:
Code:
setbar(float percentage);
but percentage is never a float. if i check it right after i set it (the comment "check here") or within the function setbar, it's either 0 or 1, like it's just an int. the only time it works is if a==b, in which case i tell it to pass 0.5 as the argument. The one thing i notice is that whenever b != 0, percentage is always 0, leading to the conclusion that a/(a+b) is doing the same thing as (int)(a/(a+b))
what am i doing wrong?