Skip to content

Commit a1266be

Browse files
fix
Signed-off-by: before-Sunrise <[email protected]>
1 parent eb792ff commit a1266be

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

be/src/runtime/decimalv3.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,27 @@ class DecimalV3Cast {
255255
}
256256

257257
template <typename From, typename To>
258-
static inline bool to_float(DecimalType<From> const& value, DecimalType<From> const& scale_factor,
259-
FloatType<To>* to_value) {
260-
*to_value = static_cast<To>(static_cast<double>(value) / static_cast<double>(scale_factor));
261-
return false;
262-
}
258+
struct ToFloatHelper {
259+
static bool convert(DecimalType<From> const& value, DecimalType<From> const& scale_factor,
260+
FloatType<To>* to_value) {
261+
*to_value = static_cast<To>(static_cast<double>(value) / static_cast<double>(scale_factor));
262+
return false;
263+
}
264+
};
263265

264266
template <typename To>
265-
static inline bool to_float(DecimalType<int128_t> const& value, DecimalType<int128_t> const& scale_factor,
267+
struct ToFloatHelper<__int128, To> {
268+
static bool convert(DecimalType<__int128> const& value, DecimalType<__int128> const& scale_factor,
269+
FloatType<To>* to_value) {
270+
*to_value = static_cast<To>(int128_to_double(value) / int128_to_double(scale_factor));
271+
return false;
272+
}
273+
};
274+
275+
template <typename From, typename To>
276+
static inline bool to_float(DecimalType<From> const& value, DecimalType<From> const& scale_factor,
266277
FloatType<To>* to_value) {
267-
*to_value = static_cast<To>(int128_to_double(value) / int128_to_double(scale_factor));
268-
return false;
278+
return ToFloatHelper<From, To>::convert(value, scale_factor, to_value);
269279
}
270280

271281
template <typename From, typename To, bool check_overflow>

0 commit comments

Comments
 (0)