Decimal128 DecimalUtil::multiplyByPowerOf10(Decimal128 value, Decimal128 exponent) { Decimal128 result = value; decQuadScaleB(result.data(), value.data(), exponent.data(), getContext()); return result; }
Decimal128 DecimalUtil::fabs(Decimal128 value) { #if BDLDFP_DECIMALPLATFORM_C99_TR return fabsd128(value.value()); #elif BDLDFP_DECIMALPLATFORM_DECNUMBER Decimal128 rv; decQuadAbs(rv.data(), value.data(), getContext()); return rv; #endif }
Decimal128 DecimalUtil::fma(Decimal128 x, Decimal128 y, Decimal128 z) { #if BDLDFP_DECIMALPLATFORM_C99_TR return fmad128(x.value(), y.value(), z.value()); #elif BDLDFP_DECIMALPLATFORM_DECNUMBER Decimal128 rv; decQuadFMA(rv.data(), x.data(), y.data(), z.data(), getContext()); return rv; #endif }
Decimal128 DecimalUtil::multiplyByPowerOf10(Decimal128 value, int exponent) { BSLS_ASSERT(-1999999997 <= exponent); BSLS_ASSERT( exponent <= 99999999); Decimal128 result = value; DecimalImplUtil::ValueType128 scale = DecimalImplUtil::makeDecimalRaw128(exponent, 0); decQuadScaleB(result.data(), value.data(), &scale, getContext()); return result; }
Decimal128 DecimalUtil::round(Decimal128 x) { #if BDLDFP_DECIMALPLATFORM_C99_TR return roundd128(x.value()); #elif BDLDFP_DECIMALPLATFORM_DECNUMBER Decimal128 rv; decQuadToIntegralValue(rv.data(), x.data(), getContext(), DEC_ROUND_HALF_UP); return rv; #endif }
Decimal128 DecimalUtil::ceil(Decimal128 x) { #if BDLDFP_DECIMALPLATFORM_C99_TR return ceild128(x.value()); #elif BDLDFP_DECIMALPLATFORM_DECNUMBER Decimal128 rv; decQuadToIntegralValue(rv.data(), x.data(), getContext(), DEC_ROUND_CEILING); return rv; #endif }
int DecimalUtil::quantum(Decimal128 x) { BSLS_ASSERT(!isInf(x)); BSLS_ASSERT(!isNan(x)); return decQuadGetExponent(x.data()); }
int DecimalUtil::classify(Decimal128 x) { #if BDLDFP_DECIMALPLATFORM_C99_TR return fpclassify(x.value()); #elif BDLDFP_DECIMALPLATFORM_DECNUMBER enum decClass cl = decQuadClass(x.data()); return deClass2FP_(cl); #endif }
bool DecimalUtil::sameQuantum(Decimal128 x, Decimal128 y) { return decQuadSameQuantum(x.data(), y.data()) == 1; }
Decimal128 DecimalUtil::quantize(Decimal128 x, Decimal128 y) { Decimal128 rv = x; decQuadQuantize(rv.data(), x.data(), y.data(), getContext()); return rv; }