src/misc.cpp

changeset 223
4f95d7f2e9ef
parent 211
8d35e631bef3
child 256
9f7e6e288953
equal deleted inserted replaced
222:fddd36a6526c 223:4f95d7f2e9ef
130 130
131 // ============================================================================= 131 // =============================================================================
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
133 // ============================================================================= 133 // =============================================================================
134 // Float to string. Removes trailing zeroes and is locale-independant. 134 // Float to string. Removes trailing zeroes and is locale-independant.
135 str ftoa (double fCoord) { 135 str ftoa (double num) {
136 // Disable the locale first so that the decimal point will not 136 // Disable the locale first so that the decimal point will not
137 // turn into anything weird (like commas) 137 // turn into anything weird (like commas)
138 setlocale (LC_NUMERIC, "C"); 138 setlocale (LC_NUMERIC, "C");
139 139
140 str zRep = fmt ("%f", fCoord); 140 str zRep = fmt ("%f", num);
141 141
142 // Remove trailing zeroes 142 // Remove trailing zeroes
143 while (zRep[~zRep - 1] == '0') 143 while (zRep[~zRep - 1] == '0')
144 zRep -= 1; 144 zRep -= 1;
145 145

mercurial