8 #include <cudf/fixed_point/detail/floating_conversion.hpp>
11 #include <cudf/utilities/export.hpp>
19 namespace CUDF_EXPORT
cudf {
39 template <
typename Fixed,
41 CUDF_ENABLE_IF(cuda::std::is_floating_point_v<Floating>&& is_fixed_point<Fixed>())>
44 using Rep =
typename Fixed::rep;
45 auto const value = [&]() {
46 if constexpr (Fixed::rad == numeric::Radix::BASE_10) {
47 return numeric::detail::convert_floating_to_integral<Rep>(floating, scale);
49 return static_cast<Rep
>(numeric::detail::shift<Rep, Fixed::rad>(floating, scale));
69 template <
typename Floating,
71 CUDF_ENABLE_IF(cuda::std::is_floating_point_v<Floating>&& is_fixed_point<Fixed>())>
74 using Rep =
typename Fixed::rep;
75 if constexpr (Fixed::rad == numeric::Radix::BASE_10) {
76 return numeric::detail::convert_integral_to_floating<Floating>(fixed.value(), fixed.scale());
78 auto const casted =
static_cast<Floating
>(fixed.value());
80 return numeric::detail::shift<Rep, Fixed::rad>(casted, scale);
92 template <
typename Floating,
97 if constexpr (is_fixed_point<Input>()) {
98 return convert_fixed_to_floating<Floating>(input);
100 return static_cast<Floating
>(input);
Class definition for fixed point data type.
CUDF_HOST_DEVICE Floating convert_fixed_to_floating(Fixed fixed)
Convert a fixed-point value to floating point.
CUDF_HOST_DEVICE Floating convert_to_floating(Input input)
Convert a value to floating point.
scale_type
The scale type for fixed_point.
CUDF_HOST_DEVICE Fixed convert_floating_to_fixed(Floating floating, numeric::scale_type scale)
Convert a floating-point value to fixed point.
#define CUDF_ENABLE_IF(...)
Convenience macro for SFINAE as an unnamed template parameter.
Helper struct for constructing fixed_point when value is already shifted.
Type traits for classifying and querying properties of cudf column and scalar types.
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.