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 | |
Helper struct for getting and setting the components of a floating-point value.
FloatingType | Type of floating-point value |
Definition at line 88 of file floating_conversion.hpp.
|
inlinestatic |
Adds to the base-2 exponent of a floating-point number.
floating | The floating value to add to the exponent of. Must be positive. |
pow2 | The power-of-2 to add to the floating-point number |
Definition at line 266 of file floating_conversion.hpp.
|
inlinestatic |
Reinterpret the bits of an integer as floating-point value.
integer | The integer to cast |
Definition at line 153 of file floating_conversion.hpp.
|
inlinestatic |
Reinterpret the bits of a floating-point value as an integer.
floating | The floating-point value to cast |
Definition at line 139 of file floating_conversion.hpp.
|
inlinestatic |
Extracts the sign bit of a bit-casted floating-point number.
integer_rep | The bit-casted floating value to extract the exponent from |
Definition at line 179 of file floating_conversion.hpp.
|
inlinestatic |
Extracts the significand and exponent of a bit-casted floating-point number, shifted for denormals.
integer_rep | The bit-casted floating value to extract the exponent from |
Definition at line 194 of file floating_conversion.hpp.
|
inlinestatic |
Checks whether the bit-casted floating-point value is +/-0.
integer_rep | The bit-casted floating value to check if is +/-0 |
Definition at line 167 of file floating_conversion.hpp.
|
inlinestatic |
Sets the sign bit of a floating-point number.
floating | The floating-point value to set the sign of. Must be positive. |
is_negative | The sign bit to set for the floating-point number |
Definition at line 244 of file floating_conversion.hpp.
|
staticconstexpr |
Definition at line 121 of file floating_conversion.hpp.
|
staticconstexpr |
Definition at line 111 of file floating_conversion.hpp.
|
staticconstexpr |
Definition at line 113 of file floating_conversion.hpp.
|
staticconstexpr |
The mask for the exponents, unshifted.
Definition at line 123 of file floating_conversion.hpp.