float.ToString()输出小数但不四舍五入

下面代码的输出竟然是2.0:

float a=1.95f;
Debug.Log(a.ToString(“0.0”));

如果想截取一位小数,可以:

float a=1.95f;

float t_a=Mathf.Floor(a*10)*0.1f;
Debug.Log(t_a.ToString(“0.0”));

猜你喜欢

转载自blog.csdn.net/vickieyy/article/details/89884820