Datum decimal64_decimal128(PG_FUNCTION_ARGS) { PGDecimal64 a = PG_GETARG_DECIMAL64(0); DECLARE_PRET_128(pret); decDoubleToWider(&a, pret); PG_RETURN_P_DECIMAL128(pret); }
/* Use decNumber to convert directly from _Decimal64 to _Decimal128. */ _Decimal128 DFP_TO_DFP (_Decimal64 f_from) { union { _Decimal64 c; decDouble f; } from; union { _Decimal128 c; decQuad f; } to; from.c = f_from; to.f = *decDoubleToWider (&from.f, &to.f); return to.c; }
/* Use decNumber to convert directly from _Decimal32 to _Decimal128. */ _Decimal128 DFP_TO_DFP (_Decimal32 f_from) { union { _Decimal32 c; decSingle f; } from; union { _Decimal128 c; decQuad f; } to; decDouble temp; from.c = f_from; temp = *decSingleToWider (&from.f, &temp); to.f = *decDoubleToWider (&temp, &to.f); return to.c; }