unity c# float 转 string

float a=2.586;
string b=a.ToString("f3");

注:ToString后面括号中一定要加入格式"fx",x表示保留的小数点后几位,"f3"就是保留后3位。

猜你喜欢

转载自blog.csdn.net/qq_21743659/article/details/125220844