Ridiculously simple math issue: int -> float

I do no know why this is not interpreting properly or what kind of procedure Unity is looking for.

var a : int = 3;
var b : int = 2;
var result : float = (a * b) / Mathf.PI;
return result;

Result keeps coming back as zero because the (3 * 2) appears to be casting the whole value to an int. How do I get a float value into the result float?

parseFloat(a) * b / Mathf.PI

or

(a + 0.0) * b / Mathf.PI;

–Eric

Perfect, thanks.

That shouldn’t do anything at all to your results. Mathf.PI is a float, so dividing by it will yield a float. There is no way to get zero out of 6/Pi. Even if the result was an int, somehow, the int would be one, not zero. Something else is causing a problem.

I completely understand, that is why I was lost. But putting in the parseFloat fixed it.

It didn’t fix anything for me. I copied and pasted your code, but of course, that’s not enough code to test anything by itself. I couldn’t vary it to cause a problem, though.