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

Function CVT_get_int128

src/common/cvt.cpp:3142–3293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3140
3141
3142Int128 CVT_get_int128(const dsc* desc, SSHORT scale, DecimalStatus decSt, ErrorFunction err)
3143{
3144/**************************************
3145 *
3146 * C V T _ g e t _ d e c 1 2 8
3147 *
3148 **************************************
3149 *
3150 * Functional description
3151 * Convert something arbitrary to 128 bit integer.
3152 *
3153 **************************************/
3154 VaryStr<1024> buffer; // represents unreasonably long decfloat literal in ASCII
3155 Int128 int128;
3156 Decimal128 tmp;
3157 double d, eps;
3158
3159 static const double I128_MIN_dbl = -1.701411834604692e+38;
3160 static const double I128_MAX_dbl = 1.701411834604692e+38;
3161 static const CDecimal128 I128_MIN_dcft("-1.701411834604692317316873037158841E+38", decSt);
3162 static const CDecimal128 I128_MAX_dcft("1.701411834604692317316873037158841E+38", decSt);
3163 static const CDecimal128 DecFlt_05("0.5", decSt);
3164
3165 // adjust exact numeric values to same scaling
3166 if (DTYPE_IS_EXACT(desc->dsc_dtype))
3167 scale -= desc->dsc_scale;
3168
3169 const char* p = reinterpret_cast<char*>(desc->dsc_address);
3170
3171 try
3172 {
3173 switch (desc->dsc_dtype)
3174 {
3175 case dtype_short:
3176 int128.set(SLONG(*(SSHORT*) p), scale);
3177 break;
3178
3179 case dtype_long:
3180 int128.set(*(SLONG*) p, scale);
3181 break;
3182
3183 case dtype_quad:
3184 int128.set(CVT_get_int64(desc, 0, decSt, err), scale);
3185 break;
3186
3187 case dtype_int64:
3188 int128.set(*(SINT64*) p, scale);
3189 break;
3190
3191 case dtype_varying:
3192 case dtype_cstring:
3193 case dtype_text:
3194 {
3195 USHORT length =
3196 CVT_make_string(desc, ttype_ascii, &p, &buffer, sizeof(buffer), decSt, err);
3197 scale -= CVT_decompose(p, length, &int128, err);
3198 int128.setScale(scale);
3199 }

Callers 4

pass2Method · 0.85
MOV_get_int128Function · 0.85
CVT2_compareFunction · 0.85
CVT_move_commonFunction · 0.85

Calls 10

DTYPE_IS_EXACTFunction · 0.85
CVT_get_int64Function · 0.85
CVT_make_stringFunction · 0.85
CVT_decomposeFunction · 0.85
CVT_conversion_errorFunction · 0.85
CVT_power_of_tenFunction · 0.85
GdsClass · 0.85
setMethod · 0.45
setScaleMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected