| 346 | // fractional digits, and dropping trailing '0' characters. |
| 347 | |
| 348 | void FormatR(char *sz, real r, int n) |
| 349 | { |
| 350 | char szT[cchSzDef], *pch; |
| 351 | int x = n/100, y = NAbs(n%100); |
| 352 | |
| 353 | // If n > 100, use 100's place as minimum field length for entire number. |
| 354 | if (x != 0) |
| 355 | sprintf(szT, "%%%d.%df", NAbs(x) + y + 1, y); |
| 356 | else |
| 357 | sprintf(szT, "%%.%df", NAbs(n)); |
| 358 | sprintf(sz, szT, r); |
| 359 | for (pch = sz; *pch; pch++) |
| 360 | ; |
| 361 | while (pch > sz && *(--pch) == '0') // Drop off any trailing 0 digits. |
| 362 | ; |
| 363 | // Positive n means ensure at least one fractional digit. |
| 364 | pch[n > 0 ? 1 + (*pch == '.') : (*pch != '.')] = chNull; |
| 365 | } |
| 366 | |
| 367 | |
| 368 | // Blend two RGB colors along the specified proportion between them. Returned |
no outgoing calls
no test coverage detected