
fractions
Just a question about entering fractions...
I have a function set up to do a simple calculation. If I code in a whole number to be multiplied by one of the variables, it gives the right answer but if it's a fraction  ie (1/2)*x  it gives the wrong answer. The answer it gives is as if the fraction were a 0 instead. It's also wrong for fractions greater than 0 that don't reduce to a whole number, except that the answer is like the x were multiplied by the fraction rounded to a whole number.
Everything's okay if I put in the decimal instead, but I was just wondering if there's a special way to enter fractions?

(1/2) = 0.5 (however, since it's an integer division it's truncated to 0).
(1.0f / 2.0f) * (float) x
Is perhaps a better way.
int / int gives an int
float / float gives a float
double / double gives a double
So on and so forth.

Oh, awesome! Thanks, I just needed to put the .0 in...should have tried that. I'm new at this... :P