Public Types | Static Public Member Functions | Static Public Attributes | List of all members
numeric::detail::floating_converter< FloatingType, > Struct Template Reference

Helper struct for getting and setting the components of a floating-point value. More...

#include <floating_conversion.hpp>

Public Types

using IntegralType = cuda::std::conditional_t< cuda::std::is_same_v< FloatingType, float >, uint32_t, uint64_t >
 Unsigned int type with same size as floating type.
 

Static Public Member Functions

static CUDF_HOST_DEVICE IntegralType bit_cast_to_integer (FloatingType floating)
 Reinterpret the bits of a floating-point value as an integer. More...
 
static CUDF_HOST_DEVICE FloatingType bit_cast_to_floating (IntegralType integer)
 Reinterpret the bits of an integer as floating-point value. More...
 
static CUDF_HOST_DEVICE bool is_zero (IntegralType integer_rep)
 Checks whether the bit-casted floating-point value is +/-0. More...
 
static CUDF_HOST_DEVICE bool get_is_negative (IntegralType integer_rep)
 Extracts the sign bit of a bit-casted floating-point number. More...
 
static CUDF_HOST_DEVICE std::pair< IntegralType, int > get_significand_and_pow2 (IntegralType integer_rep)
 Extracts the significand and exponent of a bit-casted floating-point number, shifted for denormals. More...
 
static CUDF_HOST_DEVICE FloatingType set_is_negative (FloatingType floating, bool is_negative)
 Sets the sign bit of a floating-point number. More...
 
static CUDF_HOST_DEVICE FloatingType add_pow2 (FloatingType floating, int pow2)
 Adds to the base-2 exponent of a floating-point number. More...
 

Static Public Attributes

static constexpr int num_floating_bits = sizeof(FloatingType) * CHAR_BIT
 How many bits in the floating type.
 
static constexpr int sign_bit_index = num_floating_bits - 1
 The index of the sign bit.
 
static constexpr IntegralType sign_mask = (IntegralType(1) << sign_bit_index)
 The mask to select the sign bit.
 
static constexpr int num_significand_bits = cuda::std::numeric_limits<FloatingType>::digits
 
static constexpr int num_stored_mantissa_bits = num_significand_bits - 1
 
static constexpr IntegralType understood_bit_mask = (IntegralType(1) << num_stored_mantissa_bits)
 The mask for the understood bit.
 
static constexpr IntegralType mantissa_mask = understood_bit_mask - 1
 The mask to select the mantissa.
 
static constexpr int num_exponent_bits = num_floating_bits - num_stored_mantissa_bits - 1
 
static constexpr IntegralType unshifted_exponent_mask
 The mask for the exponents, unshifted. More...
 
static constexpr IntegralType exponent_mask = unshifted_exponent_mask << num_stored_mantissa_bits
 The mask to select the exponents.
 
static constexpr int exponent_bias = cuda::std::numeric_limits<FloatingType>::max_exponent - 1
 127 / 1023 for float / double
 

Detailed Description

template<typename FloatingType, CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >)>
struct numeric::detail::floating_converter< FloatingType, >

Helper struct for getting and setting the components of a floating-point value.

Template Parameters
FloatingTypeType of floating-point value

Definition at line 88 of file floating_conversion.hpp.

Member Function Documentation

◆ add_pow2()

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
static CUDF_HOST_DEVICE FloatingType numeric::detail::floating_converter< FloatingType, >::add_pow2 ( FloatingType  floating,
int  pow2 
)
inlinestatic

Adds to the base-2 exponent of a floating-point number.

Note
The caller must guarantee that the input is a positive (> 0) whole number.
Parameters
floatingThe floating value to add to the exponent of. Must be positive.
pow2The power-of-2 to add to the floating-point number
Returns
The input floating-point value * 2^pow2

Definition at line 266 of file floating_conversion.hpp.

◆ bit_cast_to_floating()

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
static CUDF_HOST_DEVICE FloatingType numeric::detail::floating_converter< FloatingType, >::bit_cast_to_floating ( IntegralType  integer)
inlinestatic

Reinterpret the bits of an integer as floating-point value.

Parameters
integerThe integer to cast
Returns
A floating-point value with bits identical to the input

Definition at line 153 of file floating_conversion.hpp.

◆ bit_cast_to_integer()

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
static CUDF_HOST_DEVICE IntegralType numeric::detail::floating_converter< FloatingType, >::bit_cast_to_integer ( FloatingType  floating)
inlinestatic

Reinterpret the bits of a floating-point value as an integer.

Parameters
floatingThe floating-point value to cast
Returns
An integer with bits identical to the input

Definition at line 139 of file floating_conversion.hpp.

◆ get_is_negative()

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
static CUDF_HOST_DEVICE bool numeric::detail::floating_converter< FloatingType, >::get_is_negative ( IntegralType  integer_rep)
inlinestatic

Extracts the sign bit of a bit-casted floating-point number.

Parameters
integer_repThe bit-casted floating value to extract the exponent from
Returns
The sign bit

Definition at line 179 of file floating_conversion.hpp.

◆ get_significand_and_pow2()

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
static CUDF_HOST_DEVICE std::pair<IntegralType, int> numeric::detail::floating_converter< FloatingType, >::get_significand_and_pow2 ( IntegralType  integer_rep)
inlinestatic

Extracts the significand and exponent of a bit-casted floating-point number, shifted for denormals.

Note
Zeros/inf/NaN not handled.
Parameters
integer_repThe bit-casted floating value to extract the exponent from
Returns
The stored base-2 exponent and significand, shifted for denormals

Definition at line 194 of file floating_conversion.hpp.

◆ is_zero()

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
static CUDF_HOST_DEVICE bool numeric::detail::floating_converter< FloatingType, >::is_zero ( IntegralType  integer_rep)
inlinestatic

Checks whether the bit-casted floating-point value is +/-0.

Parameters
integer_repThe bit-casted floating value to check if is +/-0
Returns
True if is a zero, else false

Definition at line 167 of file floating_conversion.hpp.

◆ set_is_negative()

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
static CUDF_HOST_DEVICE FloatingType numeric::detail::floating_converter< FloatingType, >::set_is_negative ( FloatingType  floating,
bool  is_negative 
)
inlinestatic

Sets the sign bit of a floating-point number.

Parameters
floatingThe floating-point value to set the sign of. Must be positive.
is_negativeThe sign bit to set for the floating-point number
Returns
The input floating-point value with the chosen sign

Definition at line 244 of file floating_conversion.hpp.

Member Data Documentation

◆ num_exponent_bits

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
constexpr int numeric::detail::floating_converter< FloatingType, >::num_exponent_bits = num_floating_bits - num_stored_mantissa_bits - 1
staticconstexpr

exponents bits (-1 for sign bit)

Definition at line 121 of file floating_conversion.hpp.

◆ num_significand_bits

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
constexpr int numeric::detail::floating_converter< FloatingType, >::num_significand_bits = cuda::std::numeric_limits<FloatingType>::digits
staticconstexpr

significand bits (includes understood bit)

Definition at line 111 of file floating_conversion.hpp.

◆ num_stored_mantissa_bits

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
constexpr int numeric::detail::floating_converter< FloatingType, >::num_stored_mantissa_bits = num_significand_bits - 1
staticconstexpr

stored mantissa bits (-1 for understood bit)

Definition at line 113 of file floating_conversion.hpp.

◆ unshifted_exponent_mask

template<typename FloatingType , CUDF_ENABLE_IF(cuda::std::is_floating_point_v< FloatingType >) >
constexpr IntegralType numeric::detail::floating_converter< FloatingType, >::unshifted_exponent_mask
staticconstexpr
Initial value:
=
cuda::std::conditional_t< cuda::std::is_same_v< FloatingType, float >, uint32_t, uint64_t > IntegralType
Unsigned int type with same size as floating type.

The mask for the exponents, unshifted.

Definition at line 123 of file floating_conversion.hpp.


The documentation for this struct was generated from the following file: