- Home /
Shown decimal places
my current code:
private GUILabel windSpeedText;
private float windSpeed = 5;
windSpeedText.text = "" + Mathf.Round(windSpeed * 100.0f) / 100.0f;
current Output: 5 Wanted Output: 5.00
I would always like to always have 2 decimal places following the number.
Comment
Best Answer
Answer by J3-Gaming · Jul 27, 2011 at 11:43 PM
nvm, found it
windSpeedText.text = string.Format("{0:0.00}", Mathf.Round(windSpeed * 100.0f) / 100.0f);
Answer by DaveA · Jul 27, 2011 at 11:40 PM
Check this: http://msdn.microsoft.com/en-us/library/fht0f5be.aspx and this: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
well then you should've answered your own question and provided the links. ;-)
Your answer
Follow this Question
Related Questions
I dont want Decimals :P 1 Answer
Round to decimals 2 Answers
print to only two decimal places. 2 Answers
How do you convert Random.Range to two decimal places? 1 Answer
round float with 2 decimal 6 Answers