Show 1 decimal only when printing a float

Is there any way to print a float and have it only show 1 decimal?

e.g Float = 2.123131231, I want it to print Float = 2.1

At the moment im using Mathf.Floor(float) but that shows only the int.

Thanks in advance!

You can use ToString(“F1”):

  var division: float = 1.0/3;
  guiText.text = division.ToString("F1");

“F1” shows one decimal digit, “F2” shows 2 digits, and so on.

Javascript:

`var number = Mathf.PI;`

`Debug.Log(Mathf.Round(number * 10)/10);`

C#:

float number = Mathf.PI;

Debug.Log(number.ToString("0.0"));