8 #include <cudf/fixed_point/detail/floating_conversion.hpp>
11 #include <cudf/utilities/export.hpp>
14 namespace CUDF_EXPORT
cudf {
36 template <
typename Fixed,
38 CUDF_ENABLE_IF(cuda::std::is_floating_point_v<Floating>&& is_fixed_point<Fixed>())>
41 using Rep =
typename Fixed::rep;
42 auto const value = [&]() {
43 if constexpr (Fixed::rad == numeric::Radix::BASE_10) {
44 return numeric::detail::convert_floating_to_integral<Rep>(floating, scale);
46 return static_cast<Rep
>(numeric::detail::shift<Rep, Fixed::rad>(floating, scale));
66 template <
typename Floating,
68 CUDF_ENABLE_IF(cuda::std::is_floating_point_v<Floating>&& is_fixed_point<Fixed>())>
71 using Rep =
typename Fixed::rep;
72 if constexpr (Fixed::rad == numeric::Radix::BASE_10) {
73 return numeric::detail::convert_integral_to_floating<Floating>(fixed.value(), fixed.scale());
75 auto const casted =
static_cast<Floating
>(fixed.value());
77 return numeric::detail::shift<Rep, Fixed::rad>(casted, scale);
89 template <
typename Floating,
94 if constexpr (is_fixed_point<Input>()) {
95 return convert_fixed_to_floating<Floating>(input);
97 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.