19 #include <cudf/fixed_point/detail/floating_conversion.hpp>
22 #include <cudf/utilities/export.hpp>
25 namespace CUDF_EXPORT
cudf {
47 template <
typename Fixed,
49 CUDF_ENABLE_IF(cuda::std::is_floating_point_v<Floating>&& is_fixed_point<Fixed>())>
52 using Rep =
typename Fixed::rep;
53 auto const value = [&]() {
54 if constexpr (Fixed::rad == numeric::Radix::BASE_10) {
55 return numeric::detail::convert_floating_to_integral<Rep>(floating, scale);
57 return static_cast<Rep
>(numeric::detail::shift<Rep, Fixed::rad>(floating, scale));
77 template <
typename Floating,
79 CUDF_ENABLE_IF(cuda::std::is_floating_point_v<Floating>&& is_fixed_point<Fixed>())>
82 using Rep =
typename Fixed::rep;
83 if constexpr (Fixed::rad == numeric::Radix::BASE_10) {
84 return numeric::detail::convert_integral_to_floating<Floating>(fixed.value(), fixed.scale());
86 auto const casted =
static_cast<Floating
>(fixed.value());
88 return numeric::detail::shift<Rep, Fixed::rad>(casted, scale);
100 template <
typename Floating,
105 if constexpr (is_fixed_point<Input>()) {
106 return convert_fixed_to_floating<Floating>(input);
108 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 declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.