float debuging as whole number

I’ve thrown myself into iPhone development and I’m trying to simply debug a number however now even passing a number with a decimal place debugs as a whole number.

var percentage : float = 1.71;
Debug.Log(percentage);
gives my 1

var percentage : float = 1.0;
Debug.Log(percentage);
percentage = 1 / 4;

gives me 0

I’ve not done much Unity before so I could be doing something stupid, however I’ve got years of actionscript as2 and as3 and just can’t figure this one out.

cheers
g

This doesn’t happen to me. I get 1.71

That doesn’t happen to me either, because you’re logging before
you assign a new value. Therefore, I get 1. If you do this, however:

var percentage : float = 1.0;
percentage = 1 / 4;
Debug.Log(percentage);

you will get 0, because you’re performing integer division, and storing that as a float (so it’s really 0.00000…). Change 1 to 1.0 or 4 to 4.0, and you should be all set.