- Home /
Question by
bigbq · Nov 08, 2014 at 11:48 PM ·
floatrandom.rangedecimal
How do you convert Random.Range to two decimal places?
(Javasctipt) How would i convert this to two decimal places instead of getting random numbers like 0.35678 instead of 0.35 debt1change = Random.Range(0.1,0.5);
Comment
Take a look at this post :
http://answers.unity3d.com/questions/50391/how-to-round-a-float-to-2-dp.html
Answer by Baste · Nov 08, 2014 at 11:59 PM
To remove everything after two decimal places, just remove the modulo of 0.01:
0.35678 - (0.35678 % 0.01) = 0.35
Your answer
Follow this Question
Related Questions
I dont want Decimals :P 1 Answer
Have random.range anims access float speed variable 0 Answers
What is the max float? -1 Answers
Javascript rounding off a decimal 0 Answers
How to put Random.range in float array? 3 Answers