Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: before-Sunrise <[email protected]>
  • Loading branch information
before-Sunrise committed Jan 16, 2025
1 parent eb792ff commit a1266be
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions be/src/runtime/decimalv3.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,27 @@ class DecimalV3Cast {
}

template <typename From, typename To>
static inline bool to_float(DecimalType<From> const& value, DecimalType<From> const& scale_factor,
FloatType<To>* to_value) {
*to_value = static_cast<To>(static_cast<double>(value) / static_cast<double>(scale_factor));
return false;
}
struct ToFloatHelper {
static bool convert(DecimalType<From> const& value, DecimalType<From> const& scale_factor,
FloatType<To>* to_value) {
*to_value = static_cast<To>(static_cast<double>(value) / static_cast<double>(scale_factor));
return false;
}
};

template <typename To>
static inline bool to_float(DecimalType<int128_t> const& value, DecimalType<int128_t> const& scale_factor,
struct ToFloatHelper<__int128, To> {
static bool convert(DecimalType<__int128> const& value, DecimalType<__int128> const& scale_factor,
FloatType<To>* to_value) {
*to_value = static_cast<To>(int128_to_double(value) / int128_to_double(scale_factor));
return false;
}
};

template <typename From, typename To>
static inline bool to_float(DecimalType<From> const& value, DecimalType<From> const& scale_factor,
FloatType<To>* to_value) {
*to_value = static_cast<To>(int128_to_double(value) / int128_to_double(scale_factor));
return false;
return ToFloatHelper<From, To>::convert(value, scale_factor, to_value);
}

template <typename From, typename To, bool check_overflow>
Expand Down

0 comments on commit a1266be

Please sign in to comment.