You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
MCOL-4361 Replace pow(10.0, (double)scale) expressions with a static dictionary lookup.
This commit is contained in:
@ -195,6 +195,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
T applySignedScale(const T & val, int32_t scale)
|
||||
{
|
||||
return scale < 0 ?
|
||||
val / datatypes::scaleDivisor<T>((uint32_t) -scale) :
|
||||
val * datatypes::scaleDivisor<T>((uint32_t) scale);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief The function to produce scale multiplier/divisor for
|
||||
wide decimals.
|
||||
@ -267,6 +275,14 @@ public:
|
||||
{
|
||||
return DecomposedDecimal<int64_t>(value, scale).toSIntCeil();
|
||||
}
|
||||
|
||||
// Convert to an arbitrary floating point data type,
|
||||
// e.g. float, double, long double
|
||||
template<typename T>
|
||||
T toXFloat(uint32_t scale) const
|
||||
{
|
||||
return (T) value / scaleDivisor<T>(scale);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -590,6 +606,11 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
return TDecimal64::toUInt64Round((uint32_t) scale);
|
||||
}
|
||||
|
||||
template<typename T> T decimal64ToXFloat() const
|
||||
{
|
||||
return TDecimal64::toXFloat<T>((uint32_t) scale);
|
||||
}
|
||||
|
||||
int64_t toSInt64Round() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
|
Reference in New Issue
Block a user