| 273 | ////////////////////////////////////////////////////////////////////////// |
| 274 | |
| 275 | static int ToString(float d, char* outStr, bool roundTrip) |
| 276 | { |
| 277 | if (!roundTrip) |
| 278 | { |
| 279 | int digits; |
| 280 | if (d > 100000) |
| 281 | digits = 1; |
| 282 | else if (d > 10000) |
| 283 | digits = 2; |
| 284 | else if (d > 1000) |
| 285 | digits = 3; |
| 286 | else if (d > 100) |
| 287 | digits = 4; |
| 288 | else if (d > 10) |
| 289 | digits = 5; |
| 290 | else |
| 291 | digits = 6; |
| 292 | |
| 293 | sprintf(outStr, "%1.*f", digits, d); |
| 294 | } |
| 295 | else |
| 296 | sprintf(outStr, "%1.9g", d); |
| 297 | |
| 298 | int len = (int)strlen(outStr); |
| 299 | for (int i = 0; outStr[i] != 0; i++) |
| 300 | { |
| 301 | if (outStr[i] == '.') |
| 302 | { |
| 303 | int checkC = len - 1; |
| 304 | while (true) |
| 305 | { |
| 306 | char c = outStr[checkC]; |
| 307 | if (c == '.') |
| 308 | { |
| 309 | return checkC; |
| 310 | } |
| 311 | else if (c == 'e') |
| 312 | { |
| 313 | return len; |
| 314 | } |
| 315 | else if (c != '0') |
| 316 | { |
| 317 | for (int j = i + 1; j <= checkC; j++) |
| 318 | if (outStr[j] == 'e') |
| 319 | return len; |
| 320 | return checkC + 1; |
| 321 | } |
| 322 | checkC--; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | if ((len == 3) && (outStr[0] == 'i')) |
| 327 | { |
| 328 | strcpy(outStr, "Infinity"); |
| 329 | return 8; |
| 330 | } |
| 331 | if ((len == 4) && (outStr[0] == '-') && (outStr[1] == 'i')) |
| 332 | { |
no outgoing calls
no test coverage detected