fixed_point <--> floating-point conversion functions. More...
#include <cudf/utilities/export.hpp>
#include <cudf/utilities/traits.hpp>
#include <cuda/std/cmath>
#include <cuda/std/limits>
#include <cuda/std/type_traits>
#include <cstring>
Go to the source code of this file.
Classes | |
struct | numeric::detail::floating_converter< FloatingType, > |
Helper struct for getting and setting the components of a floating-point value. More... | |
struct | numeric::detail::shifting_constants< FloatingType > |
Helper struct with common constants needed by the floating <--> decimal conversions. More... | |
Namespaces | |
numeric | |
fixed_point and supporting types | |
Functions | |
template<typename T , CUDF_ENABLE_IF(std::is_same_v< T, uint32_t >||std::is_same_v< T, uint64_t >|| std::is_same_v< T, __uint128_t >) > | |
CUDF_HOST_DEVICE int | numeric::detail::count_significant_bits (T value) |
Determine the number of significant bits in an integer. More... | |
template<int Pow10> | |
constexpr __uint128_t | numeric::detail::large_power_of_10 () |
Recursively calculate a signed large power of 10 (>= 10^19) that can only be stored in an 128bit integer. More... | |
template<typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
CUDF_HOST_DEVICE T | numeric::detail::divide_power10_32bit (T value, int pow10) |
Divide by a power of 10 that fits within a 32bit integer. More... | |
template<typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
CUDF_HOST_DEVICE T | numeric::detail::divide_power10_64bit (T value, int pow10) |
Divide by a power of 10 that fits within a 64bit integer. More... | |
template<typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
constexpr CUDF_HOST_DEVICE T | numeric::detail::divide_power10_128bit (T value, int pow10) |
Divide by a power of 10 that fits within a 128bit integer. More... | |
template<typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
constexpr CUDF_HOST_DEVICE T | numeric::detail::multiply_power10_32bit (T value, int pow10) |
Multiply by a power of 10 that fits within a 32bit integer. More... | |
template<typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
constexpr CUDF_HOST_DEVICE T | numeric::detail::multiply_power10_64bit (T value, int pow10) |
Multiply by a power of 10 that fits within a 64bit integer. More... | |
template<typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
constexpr CUDF_HOST_DEVICE T | numeric::detail::multiply_power10_128bit (T value, int pow10) |
Multiply by a power of 10 that fits within a 128bit integer. More... | |
template<typename Rep , typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
constexpr CUDF_HOST_DEVICE T | numeric::detail::multiply_power10 (T value, int pow10) |
Multiply an integer by a power of 10. More... | |
template<typename Rep , typename T , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< T >) > | |
constexpr CUDF_HOST_DEVICE T | numeric::detail::divide_power10 (T value, int pow10) |
Divide an integer by a power of 10. More... | |
template<typename IntegerType , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< IntegerType >) > | |
CUDF_HOST_DEVICE IntegerType | numeric::detail::guarded_left_shift (IntegerType value, int bit_shift) |
Perform a bit-shift left, guarding against undefined behavior. More... | |
template<typename IntegerType , CUDF_ENABLE_IF(cuda::std::is_unsigned_v< IntegerType >) > | |
CUDF_HOST_DEVICE IntegerType | numeric::detail::guarded_right_shift (IntegerType value, int bit_shift) |
Perform a bit-shift right, guarding against undefined behavior. More... | |
template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE cuda::std::pair< typename floating_converter< FloatingType >::IntegralType, int > | numeric::detail::add_half_if_truncates (FloatingType floating, typename floating_converter< FloatingType >::IntegralType integer_rep, int pow2, int pow10) |
Add half a bit to integer rep of floating point if conversion causes truncation. More... | |
template<typename Rep , typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE cuda::std::make_unsigned_t< Rep > | numeric::detail::shift_to_decimal_pospow (typename shifting_constants< FloatingType >::IntegerRep const base2_value, int pow2, int pow10) |
Perform base-2 -> base-10 fixed-point conversion for pow10 > 0. More... | |
template<typename Rep , typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE cuda::std::make_unsigned_t< Rep > | numeric::detail::shift_to_decimal_negpow (typename shifting_constants< FloatingType >::IntegerRep base2_value, int pow2, int pow10) |
Perform base-2 -> base-10 fixed-point conversion for pow10 < 0. More... | |
template<typename Rep , typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE cuda::std::make_unsigned_t< Rep > | numeric::detail::convert_floating_to_integral_shifting (typename floating_converter< FloatingType >::IntegralType base2_value, int pow10, int pow2) |
Perform base-2 -> base-10 fixed-point conversion. More... | |
template<typename Rep , typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE Rep | numeric::detail::convert_floating_to_integral (FloatingType const &floating, scale_type const &scale) |
Perform floating-point -> integer decimal conversion. More... | |
template<typename FloatingType , typename DecimalRep , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE auto | numeric::detail::shift_to_binary_pospow (DecimalRep decimal_rep, int pow10) |
Perform base-10 -> base-2 fixed-point conversion for pow10 > 0. More... | |
template<typename FloatingType , typename DecimalRep , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE auto | numeric::detail::shift_to_binary_negpow (DecimalRep decimal_rep, int const pow10) |
Perform base-10 -> base-2 fixed-point conversion for pow10 < 0. More... | |
template<typename FloatingType , typename Rep , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) > | |
CUDF_HOST_DEVICE FloatingType | numeric::detail::convert_integral_to_floating (Rep const &value, scale_type const &scale) |
Perform integer decimal -> floating-point conversion. More... | |
fixed_point <--> floating-point conversion functions.
Definition in file floating_conversion.hpp.
CUDF_HOST_DEVICE cuda::std::pair<typename floating_converter<FloatingType>::IntegralType, int> numeric::detail::add_half_if_truncates | ( | FloatingType | floating, |
typename floating_converter< FloatingType >::IntegralType | integer_rep, | ||
int | pow2, | ||
int | pow10 | ||
) |
Add half a bit to integer rep of floating point if conversion causes truncation.
FloatingType | Type of integer holding the floating-point significand |
floating | The floating-point number to convert |
integer_rep | The integer representation of the floating-point significand |
pow2 | The power of 2 that needs to be applied to the significand |
pow10 | The power of 10 that needs to be applied to the significand |
Definition at line 636 of file floating_conversion.hpp.
|
inline |
Perform floating-point -> integer decimal conversion.
Rep | The type of integer we are converting to, to store the decimal value |
FloatingType | The type of floating-point object we are converting from |
floating | The floating point value to convert |
scale | The desired base-10 scale factor: decimal value = returned value * 10^scale |
Definition at line 932 of file floating_conversion.hpp.
|
inline |
Perform base-2 -> base-10 fixed-point conversion.
Rep | The type of integer we are converting to, to store the decimal value |
FloatingType | The type of floating-point object we are converting from |
base2_value | The base-2 fixed-point value we are converting from |
pow2 | The number of powers of 2 to apply to convert from base-2 |
pow10 | The number of powers of 10 to apply to reach the desired scale factor |
Definition at line 880 of file floating_conversion.hpp.
|
inline |
Perform integer decimal -> floating-point conversion.
FloatingType | The type of floating-point object we are converting to |
Rep | The decimal integer type we are converting from |
value | The decimal integer to convert |
scale | The base-10 scale factor for the input integer |
Definition at line 1101 of file floating_conversion.hpp.
|
inline |
Determine the number of significant bits in an integer.
T | Type of input integer value. Must be either uint32_t, uint64_t, or __uint128_t |
value | The integer whose bits are being counted |
Definition at line 49 of file floating_conversion.hpp.
|
inlineconstexpr |
Divide an integer by a power of 10.
Rep | Representation type needed for integer exponentiation |
T | Integral type of value to be divided-from. |
value | The number to be divided-from. |
pow10 | The power-of-10 of the denominator. |
Definition at line 507 of file floating_conversion.hpp.
|
inlineconstexpr |
Divide by a power of 10 that fits within a 128bit integer.
T | Type of value to be divided-from. |
value | The number to be divided-from. |
pow10 | The power-of-10 of the denominator, from 0 to 38 inclusive. |
Definition at line 408 of file floating_conversion.hpp.
|
inline |
Divide by a power of 10 that fits within a 32bit integer.
T | Type of value to be divided-from. |
value | The number to be divided-from. |
pow10 | The power-of-10 of the denominator, from 0 to 9 inclusive. |
Definition at line 344 of file floating_conversion.hpp.
|
inline |
Divide by a power of 10 that fits within a 64bit integer.
T | Type of value to be divided-from. |
value | The number to be divided-from. |
pow10 | The power-of-10 of the denominator, from 0 to 19 inclusive. |
Definition at line 394 of file floating_conversion.hpp.
|
inline |
Perform a bit-shift left, guarding against undefined behavior.
IntegerType | Type of input unsigned integer value |
value | The integer whose bits are being shifted |
bit_shift | The number of bits to shift left |
Definition at line 529 of file floating_conversion.hpp.
|
inline |
Perform a bit-shift right, guarding against undefined behavior.
IntegerType | Type of input unsigned integer value |
value | The integer whose bits are being shifted |
bit_shift | The number of bits to shift right |
Definition at line 546 of file floating_conversion.hpp.
|
constexpr |
Recursively calculate a signed large power of 10 (>= 10^19) that can only be stored in an 128bit integer.
Pow10 | The power of 10 to calculate |
Definition at line 325 of file floating_conversion.hpp.
|
inlineconstexpr |
Multiply an integer by a power of 10.
Rep | Representation type needed for integer exponentiation |
T | Integral type of value to be multiplied. |
value | The number to be multiplied. |
pow10 | The power-of-10 of the multiplier. |
Definition at line 481 of file floating_conversion.hpp.
|
inlineconstexpr |
Multiply by a power of 10 that fits within a 128bit integer.
T | Type of value to be multiplied. |
value | The number to be multiplied. |
pow10 | The power-of-10 of the multiplier, from 0 to 38 inclusive. |
Definition at line 463 of file floating_conversion.hpp.
|
inlineconstexpr |
Multiply by a power of 10 that fits within a 32bit integer.
T | Type of value to be multiplied. |
value | The number to be multiplied. |
pow10 | The power-of-10 of the multiplier, from 0 to 9 inclusive. |
Definition at line 422 of file floating_conversion.hpp.
|
inlineconstexpr |
Multiply by a power of 10 that fits within a 64bit integer.
T | Type of value to be multiplied. |
value | The number to be multiplied. |
pow10 | The power-of-10 of the multiplier, from 0 to 19 inclusive. |
Definition at line 449 of file floating_conversion.hpp.
|
inline |
Perform base-10 -> base-2 fixed-point conversion for pow10 < 0.
DecimalRep | The decimal integer type we are converting from |
FloatingType | The type of floating point object we are converting to |
decimal_rep | The decimal integer to convert |
pow10 | The number of powers of 10 to apply to undo the scale factor |
Definition at line 1034 of file floating_conversion.hpp.
|
inline |
Perform base-10 -> base-2 fixed-point conversion for pow10 > 0.
DecimalRep | The decimal integer type we are converting from |
FloatingType | The type of floating point object we are converting to |
decimal_rep | The decimal integer to convert |
pow10 | The number of powers of 10 to apply to undo the scale factor |
Definition at line 971 of file floating_conversion.hpp.
|
inline |
Perform base-2 -> base-10 fixed-point conversion for pow10 < 0.
Rep | The type of the storage for the decimal value |
FloatingType | The type of the original floating-point value we are converting from |
base2_value | The base-2 fixed-point value we are converting from |
pow2 | The number of powers of 2 to apply to convert from base-2 |
pow10 | The number of powers of 10 to apply to reach the desired scale factor |
Definition at line 794 of file floating_conversion.hpp.
|
inline |
Perform base-2 -> base-10 fixed-point conversion for pow10 > 0.
Rep | The type of the storage for the decimal value |
FloatingType | The type of the original floating-point value we are converting from |
base2_value | The base-2 fixed-point value we are converting from |
pow2 | The number of powers of 2 to apply to convert from base-2 |
pow10 | The number of powers of 10 to apply to reach the desired scale factor |
Definition at line 707 of file floating_conversion.hpp.