MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / integer_to_text

Function integer_to_text

src/common/cvt.cpp:449–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447
448
449static 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

Callers 1

CVT_move_commonFunction · 0.85

Calls 11

GdsClass · 0.85
CVT_move_commonFunction · 0.85
CVT_conversion_errorFunction · 0.85
TEXT_LENFunction · 0.85
ULONGEnum · 0.85
lengthMethod · 0.45
c_strMethod · 0.45
validateLengthMethod · 0.45
getToCharsetMethod · 0.45
getCharSetMethod · 0.45
getChidMethod · 0.45

Tested by

no test coverage detected