| 447 | |
| 448 | |
| 449 | static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb) |
| 450 | { |
| 451 | /************************************** |
| 452 | * |
| 453 | * i n t e g e r _ t o _ t e x t |
| 454 | * |
| 455 | ************************************** |
| 456 | * |
| 457 | * Functional description |
| 458 | * Convert your basic binary number to |
| 459 | * nice, formatted text. |
| 460 | * |
| 461 | **************************************/ |
| 462 | |
| 463 | // For now, this routine does not handle quadwords unless this is |
| 464 | // supported by the platform as a native datatype. |
| 465 | |
| 466 | if (from->dsc_dtype == dtype_quad) |
| 467 | { |
| 468 | fb_assert(false); |
| 469 | cb->err(Arg::Gds(isc_badblk)); // internal error |
| 470 | } |
| 471 | |
| 472 | SSHORT pad_count = 0, decimal = 0, neg = 0; |
| 473 | |
| 474 | // Save (or compute) scale of source. Then convert source to ordinary |
| 475 | // longword or int64. |
| 476 | |
| 477 | SCHAR scale = from->dsc_scale; |
| 478 | |
| 479 | if (scale > 0) |
| 480 | pad_count = scale; |
| 481 | else if (scale < 0) |
| 482 | decimal = 1; |
| 483 | |
| 484 | SINT64 n; |
| 485 | dsc intermediate; |
| 486 | MOVE_CLEAR(&intermediate, sizeof(intermediate)); |
| 487 | intermediate.dsc_dtype = dtype_int64; |
| 488 | intermediate.dsc_length = sizeof(n); |
| 489 | intermediate.dsc_scale = scale; |
| 490 | intermediate.dsc_address = (UCHAR*) &n; |
| 491 | |
| 492 | CVT_move_common(from, &intermediate, 0, cb); |
| 493 | |
| 494 | // Check for negation, then convert the number to a string of digits |
| 495 | |
| 496 | FB_UINT64 u; |
| 497 | if (n >= 0) |
| 498 | u = n; |
| 499 | else |
| 500 | { |
| 501 | neg = 1; |
| 502 | u = -n; |
| 503 | } |
| 504 | |
| 505 | string temp; |
| 506 |
no test coverage detected