- Home /
Question by
FusionSausage · Oct 16, 2013 at 03:31 PM ·
decimalcalculationspercentage
Decimals to percentage
I have some code that's gonna calculate the XP of the player in percent. So I have these variables:
public float playerXP = 57f;
public float playerNextLevel = 230f;
And this is where I calculate:
Debug.Log (playerXP/playerNextLevel);
This now gives me
0.2478261
But how do I make it a whole percentage without decimals? Like 24% instead of 0.2478261
Thank you!
Comment
Best Answer
Answer by DarkPixel · Oct 16, 2013 at 03:36 PM
That's really basic Math, it's not related to Unity at all
Just multiply by 100
Damn, I'm stupid, sorry :P Well, I tried with multipling by 10 so I thought right though :p Thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220613120039im_/https://answers.unity.com/themes/thub/images/avi.jpg)