| 6454 | } |
| 6455 | |
| 6456 | txString fxNumberToString(void* the, txNumber theValue, txString theBuffer, txSize theSize, txByte theMode, txInteger thePrecision) |
| 6457 | { |
| 6458 | ThInfo DTOA; |
| 6459 | char* base = C_NULL; |
| 6460 | int mode, precision, decpt, sign, count, exponent, pad; |
| 6461 | char* start; |
| 6462 | char* stop; |
| 6463 | char* result; |
| 6464 | |
| 6465 | fxDTOASetup(the, &DTOA); |
| 6466 | switch (theMode) { |
| 6467 | case 'e': |
| 6468 | if (thePrecision > 0) { |
| 6469 | mode = 2; |
| 6470 | precision = thePrecision; |
| 6471 | } |
| 6472 | else { |
| 6473 | mode = 0; |
| 6474 | precision = 0; |
| 6475 | } |
| 6476 | break; |
| 6477 | case 'f': |
| 6478 | mode = 3; |
| 6479 | precision = thePrecision; |
| 6480 | break; |
| 6481 | case 'g': |
| 6482 | mode = 2; |
| 6483 | precision = thePrecision; |
| 6484 | break; |
| 6485 | default: |
| 6486 | mode = 0; |
| 6487 | precision = 0; |
| 6488 | break; |
| 6489 | } |
| 6490 | base = start = fx_dtoa(theValue, mode, precision, &decpt, &sign, &stop, &DTOA); |
| 6491 | count = mxPtrDiff(stop - start); |
| 6492 | result = theBuffer; |
| 6493 | theSize--; // C string |
| 6494 | if (sign && theValue) { |
| 6495 | *result++ = '-'; |
| 6496 | theSize--; |
| 6497 | } |
| 6498 | if (decpt != 9999) { |
| 6499 | switch (theMode) { |
| 6500 | case 'e': |
| 6501 | exponent = 1; |
| 6502 | if (thePrecision > 0) |
| 6503 | pad = thePrecision; |
| 6504 | else |
| 6505 | pad = count; |
| 6506 | break; |
| 6507 | case 'f': |
| 6508 | exponent = 0; |
| 6509 | pad = thePrecision; |
| 6510 | break; |
| 6511 | case 'g': |
| 6512 | if ((decpt < -5) || (thePrecision < decpt)) { |
| 6513 | exponent = 1; |
no test coverage detected