{
// inhibit stupid negative zero
if (number == 0) number = 0;
- // we have sprintf...
return sprintf("%.*f", decimals, number);
}
-// strips trailing 0s from a float number, e.g. 1.200000 -> 1.2
+/**
+ * converts a number to a string with the minimum number of decimals
+ */
string ftos_mindecimals(float number)
{
- string s = ftos(number);
- int k = strstrofs(s, ".", 0);
- if(k >= 0)
- {
- int i = strlen(s);
- while(substring(s, i - 1, 1) == "0") i--;
- s = substring(s, 0, i);
- }
- return s;
+ // inhibit stupid negative zero
+ if (number == 0) number = 0;
+ return sprintf("%.7g", number);
}
int vercmp_recursive(string v1, string v2)