jaulib v1.4.1-14-g15926ba
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
Float types and arithmetic

Float types and arithmetic, see also and meta-group Math Support. More...

Namespaces

namespace  jau::float_literals
 
namespace  jau::string_literals
 

Classes

class  jau::float_ctti
 
class  jau::string_ctti
 

Typedefs

typedef jau::uint_bytes_t< sizeof(float64_t)> jau::double_uint_t
 
typedef float jau::float32_t
 
typedef double jau::float64_t
 
typedef jau::uint_bytes_t< sizeof(float)> jau::float_uint_t
 
typedef float jau::si_lengthf32_t
 Length in fractions of meter using float.
 
typedef float jau::si_massf32_t
 Mass in fractions of kilograms using float.
 
typedef float jau::si_speedf32_t
 Speed in fractions of meter/seconds using float.
 
typedef float jau::si_timef32_t
 Time in fractions of seconds using float.
 
typedef std::basic_ostream< uchar8_tjau::u8ostream
 
typedef std::basic_string< uchar8_tjau::u8string
 
typedef std::basic_string_view< uchar8_tjau::u8string_view
 
typedef uint8_t jau::uchar8_t
 

Functions

template<std::floating_point T>
constexpr T jau::adeg_to_rad (const T arc_degree) noexcept
 Converts arc-degree to radians.
 
template<std::floating_point T>
constexpr bool jau::almost_equal (const T &a, const T &b, int ulp=1, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true, if both floating point values are equal in the sense that their potential difference is less or equal epsilon * |a+b| * ulp, where |a+b| scales epsilon to the magnitude of used values.
 
constexpr uint32_t jau::bit_value (const float a) noexcept
 Returns the unsigned integer representation according to IEEE 754 (IEC 559) single floating-point bit layout.
 
constexpr uint64_t jau::bit_value (const float64_t a) noexcept
 Returns the unsigned integer representation according to IEEE 754 (IEC 559) float64_t floating-point bit layout.
 
constexpr uint32_t jau::bit_value_raw (const float a) noexcept
 Returns the unsigned integer representation according to IEEE 754 (IEC 559) single floating-point bit layout.
 
constexpr uint64_t jau::bit_value_raw (const float64_t a) noexcept
 Returns the unsigned integer representation according to IEEE 754 (IEC 559) float64_t floating-point bit layout.
 
template<std::floating_point T>
jau::uint_bytes_t< sizeof(T)> jau::bit_value_raw (const T a) noexcept
 Returns the unsigned integer representation according to IEEE 754 (IEC 559) floating-point bit layout.
 
template<std::floating_point T>
constexpr int jau::compare (const T a, const T b) noexcept
 Returns -1, 0 or 1 if a is less, equal or greater than b, disregarding epsilon but considering NaN, -Inf and +Inf.
 
template<std::floating_point T>
constexpr int jau::compare (const T a, const T b, const T epsilon) noexcept
 Returns -1, 0 or 1 if a is less, equal or greater than b, considering epsilon and NaN, -Inf and +Inf.
 
constexpr float64_t jau::double_value (const uint64_t a) noexcept
 Converting IEEE 754 (IEC 559) float64_t floating-point bit layout to float64_t, see bit_value()
 
template<std::floating_point T>
constexpr bool jau::equals (const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if both values are equal, i.e.
 
template<std::floating_point T>
constexpr bool jau::equals (const T &a, const T &b, int ulp, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true, if both floating point values are equal in the sense that their potential difference is less or equal epsilon * ulp.
 
template<std::floating_point T>
constexpr bool jau::equals2 (const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if both values are equal, i.e.
 
template<std::floating_point T>
constexpr bool jau::equals_raw (const T &a, const T &b) noexcept
 Returns true if both values are equal disregarding epsilon but considering NaN, -Inf and +Inf.
 
constexpr uint32_t jau::exponent_raw (float32_t a) noexcept
 Extracts the 8-bit exponent from the given IEEE 754 (IEC 559) float32_t.
 
constexpr uint32_t jau::exponent_raw (float64_t a) noexcept
 Extracts the 11-bit exponent from the given IEEE 754 (IEC 559) float64_t.
 
constexpr int32_t jau::exponent_unbiased (float32_t a) noexcept
 Extracts the unbiased 8-bit exponent from the given IEEE 754 (IEC 559) float64_t and subtracts 127, i.e.
 
constexpr int32_t jau::exponent_unbiased (float64_t a) noexcept
 Extracts the unbiased 11-bit exponent from the given IEEE 754 (IEC 559) float64_t and subtracts 1023, i.e.
 
constexpr float jau::float_value (const uint32_t a) noexcept
 Converting IEEE 754 (IEC 559) single floating-point bit layout to float, see bit_value()
 
template<std::floating_point T>
constexpr bool jau::is_zero (const T &a, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if the given value is less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero2f (const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if all given values a and b are less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero3f (const T &a, const T &b, const T &c, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if all given values a, b and c are less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero4f (const T &a, const T &b, const T &c, const T &d, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if all given values a, b, c and d are less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero_raw (const T &a) noexcept
 Returns true if the given value is zero, disregarding epsilon but considering NaN, -Inf and +Inf.
 
template<std::floating_point T>
jau::machineEpsilon () noexcept
 Calculates the smallest floating point value approximation the given type T can represent, the machine epsilon of T.
 
template<std::floating_point T>
std::string & jau::mat_to_string (std::string &sb, const std::string &rowPrefix, const std::string_view f, const T a[], const jau::nsize_t rows, const jau::nsize_t columns, const bool rowMajorOrder) noexcept
 Appends a matrix of floating points to the given string sb
 
template<std::floating_point T>
constexpr T jau::rad_to_adeg (const T rad) noexcept
 Converts radians to arc-degree.
 
template<std::floating_point T>
constexpr jau::sint_bytes_t< sizeof(T)> jau::round_to_int (const T v) noexcept
 Returns the rounded value cast to signed int.
 
template<std::floating_point T>
constexpr jau::uint_bytes_t< sizeof(T)> jau::round_to_uint (const T v) noexcept
 Returns the rounded value cast to unsigned int.
 
template<std::floating_point T>
std::string & jau::row_to_string (std::string &sb, const std::string_view f, const T a[], const jau::nsize_t rows, const jau::nsize_t columns, const bool rowMajorOrder, const jau::nsize_t row) noexcept
 Appends a row of floating points to the given string sb
 
constexpr uint32_t jau::significand_raw (float32_t a) noexcept
 Extracts the 23-bit significand (fraction, mantissa) from the given IEEE 754 (IEC 559) float32_t.
 
constexpr uint64_t jau::significand_raw (float64_t a) noexcept
 Extracts the 52-bit significand (fraction, mantissa) from the given IEEE 754 (IEC 559) float64_t.
 

Variables

constexpr uint64_t const jau::double_iec559_exp_mask = 0x7ff0000000000000_u64
 Exponent mask bits 52-62 of IEEE 754 (IEC 559) double double-point bit layout, i.e.
 
constexpr uint64_t const jau::double_iec559_mant_mask = 0x000fffffffffffff_u64
 Mantissa mask bits 0-51 of IEEE 754 (IEC 559) double double-point bit layout, i.e.
 
constexpr uint64_t const jau::double_iec559_nan_bitval = 0x7ff8000000000000_u64
 NaN bit-value of IEEE 754 (IEC 559) double double-point bit layout, i.e.
 
constexpr uint64_t const jau::double_iec559_negative_inf_bitval = 0xfff0000000000000_u64
 Negative infinity bit-value of IEEE 754 (IEC 559) double double-point bit layout, i.e.
 
constexpr uint64_t const jau::double_iec559_positive_inf_bitval = 0x7ff0000000000000_u64
 Positive infinity bit-value of IEEE 754 (IEC 559) double double-point bit layout, i.e.
 
constexpr uint64_t const jau::double_iec559_sign_bit = 1_u64 << 63
 Signed bit 63 of IEEE 754 (IEC 559) double double-point bit layout, i.e.
 
constexpr uint32_t const jau::float_iec559_exp_mask = 0x7f800000_u32
 Exponent mask bits 23-30 of IEEE 754 (IEC 559) single float-point bit layout, i.e.
 
constexpr uint32_t const jau::float_iec559_mant_mask = 0x007fffff_u32
 Mantissa mask bits 0-22 of IEEE 754 (IEC 559) single float-point bit layout, i.e.
 
constexpr uint32_t const jau::float_iec559_nan_bitval = 0x7fc00000_u32
 NaN bit-value of IEEE 754 (IEC 559) single float-point bit layout, i.e.
 
constexpr uint32_t const jau::float_iec559_negative_inf_bitval = 0xff800000_u32
 Negative infinity bit-value of IEEE 754 (IEC 559) single float-point bit layout, i.e.
 
constexpr uint32_t const jau::float_iec559_positive_inf_bitval = 0x7f800000_u32
 Positive infinity bit-value of IEEE 754 (IEC 559) single float-point bit layout, i.e.
 
constexpr uint32_t const jau::float_iec559_sign_bit = 1_u32 << 31
 Signed bit 31 of IEEE 754 (IEC 559) single float-point bit layout, i.e.
 

Detailed Description

Float types and arithmetic, see also and meta-group Math Support.

Typedef Documentation

◆ si_timef32_t

typedef float jau::si_timef32_t

Time in fractions of seconds using float.

Definition at line 36 of file float_si_types.hpp.

◆ si_lengthf32_t

typedef float jau::si_lengthf32_t

Length in fractions of meter using float.

Definition at line 38 of file float_si_types.hpp.

◆ si_massf32_t

typedef float jau::si_massf32_t

Mass in fractions of kilograms using float.

Definition at line 40 of file float_si_types.hpp.

◆ si_speedf32_t

typedef float jau::si_speedf32_t

Speed in fractions of meter/seconds using float.

Definition at line 42 of file float_si_types.hpp.

◆ float32_t

typedef float jau::float32_t

Definition at line 51 of file float_types.hpp.

◆ float64_t

typedef double jau::float64_t

Definition at line 52 of file float_types.hpp.

◆ float_uint_t

typedef jau::uint_bytes_t<sizeof(float)> jau::float_uint_t

Definition at line 66 of file float_types.hpp.

◆ double_uint_t

Definition at line 67 of file float_types.hpp.

◆ uchar8_t

typedef uint8_t jau::uchar8_t

Definition at line 47 of file string_types.hpp.

◆ u8string

typedef std::basic_string<uchar8_t> jau::u8string

Definition at line 48 of file string_types.hpp.

◆ u8string_view

typedef std::basic_string_view<uchar8_t> jau::u8string_view

Definition at line 49 of file string_types.hpp.

◆ u8ostream

typedef std::basic_ostream<uchar8_t> jau::u8ostream

Definition at line 56 of file string_types.hpp.

Function Documentation

◆ machineEpsilon()

template<std::floating_point T>
T jau::machineEpsilon ( )
noexcept

Calculates the smallest floating point value approximation the given type T can represent, the machine epsilon of T.

Template Parameters
Ta non integer float type
Returns
machine epsilon of T

Definition at line 53 of file float_math.hpp.

◆ is_zero()

template<std::floating_point T>
bool jau::is_zero ( const T & a,
const T & epsilon = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true if the given value is less than epsilon, w/ epsilon > 0.

Definition at line 66 of file float_math.hpp.

Here is the caller graph for this function:

◆ is_zero2f()

template<std::floating_point T>
bool jau::is_zero2f ( const T & a,
const T & b,
const T & epsilon = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true if all given values a and b are less than epsilon, w/ epsilon > 0.

Definition at line 72 of file float_math.hpp.

◆ is_zero3f()

template<std::floating_point T>
bool jau::is_zero3f ( const T & a,
const T & b,
const T & c,
const T & epsilon = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true if all given values a, b and c are less than epsilon, w/ epsilon > 0.

Definition at line 78 of file float_math.hpp.

Here is the caller graph for this function:

◆ is_zero4f()

template<std::floating_point T>
bool jau::is_zero4f ( const T & a,
const T & b,
const T & c,
const T & d,
const T & epsilon = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true if all given values a, b, c and d are less than epsilon, w/ epsilon > 0.

Definition at line 84 of file float_math.hpp.

◆ is_zero_raw()

template<std::floating_point T>
bool jau::is_zero_raw ( const T & a)
constexprnoexcept

Returns true if the given value is zero, disregarding epsilon but considering NaN, -Inf and +Inf.

Definition at line 93 of file float_math.hpp.

Here is the caller graph for this function:

◆ compare() [1/2]

template<std::floating_point T>
int jau::compare ( const T a,
const T b )
constexprnoexcept

Returns -1, 0 or 1 if a is less, equal or greater than b, disregarding epsilon but considering NaN, -Inf and +Inf.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
  • NaN > 0
  • +Inf > -Inf
Template Parameters
Ta non integer float type
Parameters
avalue to compare
bvalue to compare

Definition at line 113 of file float_math.hpp.

Here is the caller graph for this function:

◆ compare() [2/2]

template<std::floating_point T>
int jau::compare ( const T a,
const T b,
const T epsilon )
constexprnoexcept

Returns -1, 0 or 1 if a is less, equal or greater than b, considering epsilon and NaN, -Inf and +Inf.

epsilon must be > 0.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
  • NaN > 0
  • +Inf > -Inf
Template Parameters
Ta non integer float type
Parameters
avalue to compare
bvalue to compare
epsilondefaults to std::numeric_limits<T>::epsilon(), must be > 0

Definition at line 153 of file float_math.hpp.

◆ equals_raw()

template<std::floating_point T>
bool jau::equals_raw ( const T & a,
const T & b )
constexprnoexcept

Returns true if both values are equal disregarding epsilon but considering NaN, -Inf and +Inf.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Template Parameters
Ta non integer float type
Parameters
avalue to compare
bvalue to compare

Definition at line 175 of file float_math.hpp.

Here is the caller graph for this function:

◆ equals() [1/2]

template<std::floating_point T>
bool jau::equals ( const T & a,
const T & b,
const T & allowed_deviation = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true if both values are equal, i.e.

their absolute delta < epsilon, considering epsilon and NaN, -Inf and +Inf.

epsilon must be > 0.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Template Parameters
Ta non integer float type
Parameters
avalue to compare
bvalue to compare
epsilondefaults to std::numeric_limits<T>::epsilon(), must be > 0

their absolute delta <= allowed_deviation.

Template Parameters
Tan integral type
Parameters
avalue to compare
bvalue to compare
allowed_deviationallowed deviation

Definition at line 197 of file float_math.hpp.

Here is the caller graph for this function:

◆ equals2()

template<std::floating_point T>
bool jau::equals2 ( const T & a,
const T & b,
const T & epsilon = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true if both values are equal, i.e.

their absolute delta < epsilon, considering epsilon but disregarding NaN, -Inf and +Inf.

Template Parameters
Ta non integer float type
Parameters
avalue to compare
bvalue to compare

Definition at line 215 of file float_math.hpp.

◆ equals() [2/2]

template<std::floating_point T>
bool jau::equals ( const T & a,
const T & b,
int ulp,
const T & epsilon = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true, if both floating point values are equal in the sense that their potential difference is less or equal epsilon * ulp.

epsilon must be > 0.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Template Parameters
Ta non integer float type
Parameters
avalue to compare
bvalue to compare
ulpdesired precision in ULPs (units in the last place)
epsilonthe machine epsilon of type T, defaults to std::numeric_limits<T>::epsilon()

Definition at line 237 of file float_math.hpp.

◆ almost_equal()

template<std::floating_point T>
bool jau::almost_equal ( const T & a,
const T & b,
int ulp = 1,
const T & epsilon = std::numeric_limits<T>::epsilon() )
constexprnoexcept

Returns true, if both floating point values are equal in the sense that their potential difference is less or equal epsilon * |a+b| * ulp, where |a+b| scales epsilon to the magnitude of used values.

epsilon must be > 0.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Template Parameters
Ta non integer float type
Parameters
avalue to compare
bvalue to compare
ulpdesired precision in ULPs (units in the last place), defaults to 1
epsilonthe machine epsilon of type T, defaults to std::numeric_limits<T>::epsilon()

Definition at line 260 of file float_math.hpp.

◆ round_to_int()

template<std::floating_point T>
jau::sint_bytes_t< sizeof(T)> jau::round_to_int ( const T v)
constexprnoexcept

Returns the rounded value cast to signed int.

Definition at line 274 of file float_math.hpp.

Here is the caller graph for this function:

◆ round_to_uint()

template<std::floating_point T>
jau::uint_bytes_t< sizeof(T)> jau::round_to_uint ( const T v)
constexprnoexcept

Returns the rounded value cast to unsigned int.

Definition at line 280 of file float_math.hpp.

◆ adeg_to_rad()

template<std::floating_point T>
T jau::adeg_to_rad ( const T arc_degree)
constexprnoexcept

Converts arc-degree to radians.

Definition at line 286 of file float_math.hpp.

◆ rad_to_adeg()

template<std::floating_point T>
T jau::rad_to_adeg ( const T rad)
constexprnoexcept

Converts radians to arc-degree.

Definition at line 292 of file float_math.hpp.

Here is the caller graph for this function:

◆ row_to_string()

template<std::floating_point T>
std::string & jau::row_to_string ( std::string & sb,
const std::string_view f,
const T a[],
const jau::nsize_t rows,
const jau::nsize_t columns,
const bool rowMajorOrder,
const jau::nsize_t row )
noexcept

Appends a row of floating points to the given string sb

Parameters
sbstring buffer to appends to
fformat string for each float element, e.g. "%10.5f"
athe float data of size rows x columns
rowsfloat data a size row factor
columnsfloat data a size column factor
rowMajorOrderif true floats are laid out in row-major-order, otherwise column-major-order (OpenGL)
rowselected row of float data a
Returns
given string buffer sb for chaining

Definition at line 308 of file float_math.hpp.

Here is the caller graph for this function:

◆ mat_to_string()

template<std::floating_point T>
std::string & jau::mat_to_string ( std::string & sb,
const std::string & rowPrefix,
const std::string_view f,
const T a[],
const jau::nsize_t rows,
const jau::nsize_t columns,
const bool rowMajorOrder )
noexcept

Appends a matrix of floating points to the given string sb

Parameters
sbstring buffer to appends to
rowPrefixprefix for each row
fformat string for each float element, e.g. "%10.5f"
athe float data of size rows x columns
rowsfloat data a size row factor
columnsfloat data a size column factor
rowMajorOrderif true floats are laid out in row-major-order, otherwise column-major-order (OpenGL)
Returns
given string buffer sb for chaining

Definition at line 338 of file float_math.hpp.

Here is the caller graph for this function:

◆ bit_value_raw() [1/3]

template<std::floating_point T>
jau::uint_bytes_t< sizeof(T)> jau::bit_value_raw ( const T a)
noexcept

Returns the unsigned integer representation according to IEEE 754 (IEC 559) floating-point bit layout.

Meaningful semantics are only given if true == std::numeric_limits<T>::is_iec559.

This raw method does not collapse all NaN values.

The result is a functional unsigned integer that, i.e. reversible to double via float_value() or double via double_value() depending on type T,

See specific semantics of IEEE 754 (IEC 559) single floating-point bit layout:

  • float_iec559_sign_bit
  • float_iec559_exp_mask
  • float_iec559_mant_mask
  • float_iec559_positive_inf_bitval
  • float_iec559_negative_inf_bitval
  • float_iec559_nan_bitval

See specific semantics of IEEE 754 (IEC 559) double doubleing-point bit layout:

  • double_iec559_sign_bit
  • double_iec559_exp_mask
  • double_iec559_mant_mask
  • double_iec559_positive_inf_bitval
  • double_iec559_negative_inf_bitval
  • double_iec559_nan_bitval
Template Parameters
Tfloating point type, e.g. float or double
matchingfloating point unsigned integer type, e.g. float_uint_t or double_uint_t
Parameters
afloat value
Returns
unsigned integer representation of IEEE 754 (IEC 559) floating-point bit layout
See also
float_value()
double_value()

Definition at line 141 of file float_types.hpp.

Here is the caller graph for this function:

◆ bit_value_raw() [2/3]

uint32_t jau::bit_value_raw ( const float a)
constexprnoexcept

Returns the unsigned integer representation according to IEEE 754 (IEC 559) single floating-point bit layout.

See bit_value() for details.

This raw method does not collapse all NaN values to float_iec559_nan_bitval.

Definition at line 156 of file float_types.hpp.

◆ significand_raw() [1/2]

uint32_t jau::significand_raw ( float32_t a)
constexprnoexcept

Extracts the 23-bit significand (fraction, mantissa) from the given IEEE 754 (IEC 559) float32_t.

Examples
test_stringfmt_format.cpp.

Definition at line 161 of file float_types.hpp.

Here is the caller graph for this function:

◆ exponent_raw() [1/2]

uint32_t jau::exponent_raw ( float32_t a)
constexprnoexcept

Extracts the 8-bit exponent from the given IEEE 754 (IEC 559) float32_t.

Definition at line 165 of file float_types.hpp.

Here is the caller graph for this function:

◆ exponent_unbiased() [1/2]

int32_t jau::exponent_unbiased ( float32_t a)
constexprnoexcept

Extracts the unbiased 8-bit exponent from the given IEEE 754 (IEC 559) float64_t and subtracts 127, i.e.

exponent_raw(a)-127

Examples
test_stringfmt_format.cpp.

Definition at line 170 of file float_types.hpp.

Here is the caller graph for this function:

◆ bit_value() [1/2]

uint32_t jau::bit_value ( const float a)
constexprnoexcept

Returns the unsigned integer representation according to IEEE 754 (IEC 559) single floating-point bit layout.

Meaningful semantics are only given if true == std::numeric_limits<float>::is_iec559.

All NaN values which are represented by float_iec559_nan_bitval.

The result is a functional unsigned integer that, i.e. reversible to double via float_value().

See specific semantics of IEEE 754 (IEC 559) single floating-point bit layout:

  • float_iec559_sign_bit
  • float_iec559_exp_mask
  • float_iec559_mant_mask
  • float_iec559_positive_inf_bitval
  • float_iec559_negative_inf_bitval
  • float_iec559_nan_bitval

The result is a functional unsigned integer that, i.e. reversible to float via float_value(), except all NaN values which are represented by float_iec559_nan_bitval.

Parameters
asingle float value
Returns
unsigned integer representation of IEEE 754 (IEC 559) single floating-point bit layout
See also
float_value()
bit_value_raw()

Definition at line 199 of file float_types.hpp.

Here is the caller graph for this function:

◆ float_value()

float jau::float_value ( const uint32_t a)
constexprnoexcept

Converting IEEE 754 (IEC 559) single floating-point bit layout to float, see bit_value()

Definition at line 207 of file float_types.hpp.

Here is the caller graph for this function:

◆ bit_value_raw() [3/3]

uint64_t jau::bit_value_raw ( const float64_t a)
constexprnoexcept

Returns the unsigned integer representation according to IEEE 754 (IEC 559) float64_t floating-point bit layout.

See bit_value() for details.

This raw method does not collapse all NaN values to double_iec559_nan_bitval.

Definition at line 219 of file float_types.hpp.

◆ significand_raw() [2/2]

uint64_t jau::significand_raw ( float64_t a)
constexprnoexcept

Extracts the 52-bit significand (fraction, mantissa) from the given IEEE 754 (IEC 559) float64_t.

Definition at line 224 of file float_types.hpp.

◆ exponent_raw() [2/2]

uint32_t jau::exponent_raw ( float64_t a)
constexprnoexcept

Extracts the 11-bit exponent from the given IEEE 754 (IEC 559) float64_t.

Definition at line 228 of file float_types.hpp.

◆ exponent_unbiased() [2/2]

int32_t jau::exponent_unbiased ( float64_t a)
constexprnoexcept

Extracts the unbiased 11-bit exponent from the given IEEE 754 (IEC 559) float64_t and subtracts 1023, i.e.

exponent_raw(a)-1023

Definition at line 233 of file float_types.hpp.

◆ bit_value() [2/2]

uint64_t jau::bit_value ( const float64_t a)
constexprnoexcept

Returns the unsigned integer representation according to IEEE 754 (IEC 559) float64_t floating-point bit layout.

Meaningful semantics are only given if true == std::numeric_limits<float64_t>::is_iec559.

All NaN values which are represented by double_iec559_nan_bitval.

The result is a functional unsigned integer that, i.e. reversible to float64_t via double_value().

See specific semantics of IEEE 754 (IEC 559) float64_t floating-point bit layout:

  • double_iec559_sign_bit
  • double_iec559_exp_mask
  • double_iec559_mant_mask
  • double_iec559_positive_inf_bitval
  • double_iec559_negative_inf_bitval
  • double_iec559_nan_bitval
Parameters
afloat64_t float value
Returns
unsigned integer representation of IEEE 754 (IEC 559) float64_t floating-point bit layout
See also
double_value()
bit_value_raw()

Definition at line 260 of file float_types.hpp.

◆ double_value()

float64_t jau::double_value ( const uint64_t a)
constexprnoexcept

Converting IEEE 754 (IEC 559) float64_t floating-point bit layout to float64_t, see bit_value()

Definition at line 267 of file float_types.hpp.

Here is the caller graph for this function:

Variable Documentation

◆ float_iec559_sign_bit

uint32_t const jau::float_iec559_sign_bit = 1_u32 << 31
constexpr

Signed bit 31 of IEEE 754 (IEC 559) single float-point bit layout, i.e.

0x80000000.

Definition at line 70 of file float_types.hpp.

◆ float_iec559_exp_mask

uint32_t const jau::float_iec559_exp_mask = 0x7f800000_u32
constexpr

Exponent mask bits 23-30 of IEEE 754 (IEC 559) single float-point bit layout, i.e.

0x7f800000.

Definition at line 73 of file float_types.hpp.

◆ float_iec559_mant_mask

uint32_t const jau::float_iec559_mant_mask = 0x007fffff_u32
constexpr

Mantissa mask bits 0-22 of IEEE 754 (IEC 559) single float-point bit layout, i.e.

0x007fffff.

Definition at line 76 of file float_types.hpp.

◆ float_iec559_positive_inf_bitval

uint32_t const jau::float_iec559_positive_inf_bitval = 0x7f800000_u32
constexpr

Positive infinity bit-value of IEEE 754 (IEC 559) single float-point bit layout, i.e.

0x7f800000.

Definition at line 79 of file float_types.hpp.

◆ float_iec559_negative_inf_bitval

uint32_t const jau::float_iec559_negative_inf_bitval = 0xff800000_u32
constexpr

Negative infinity bit-value of IEEE 754 (IEC 559) single float-point bit layout, i.e.

0xff800000.

Definition at line 82 of file float_types.hpp.

◆ float_iec559_nan_bitval

uint32_t const jau::float_iec559_nan_bitval = 0x7fc00000_u32
constexpr

NaN bit-value of IEEE 754 (IEC 559) single float-point bit layout, i.e.

0x7fc00000.

Definition at line 85 of file float_types.hpp.

◆ double_iec559_sign_bit

uint64_t const jau::double_iec559_sign_bit = 1_u64 << 63
constexpr

Signed bit 63 of IEEE 754 (IEC 559) double double-point bit layout, i.e.

0x8000000000000000.

Definition at line 88 of file float_types.hpp.

◆ double_iec559_exp_mask

uint64_t const jau::double_iec559_exp_mask = 0x7ff0000000000000_u64
constexpr

Exponent mask bits 52-62 of IEEE 754 (IEC 559) double double-point bit layout, i.e.

0x7ff0000000000000.

Definition at line 91 of file float_types.hpp.

◆ double_iec559_mant_mask

uint64_t const jau::double_iec559_mant_mask = 0x000fffffffffffff_u64
constexpr

Mantissa mask bits 0-51 of IEEE 754 (IEC 559) double double-point bit layout, i.e.

0x000fffffffffffff.

Definition at line 94 of file float_types.hpp.

◆ double_iec559_positive_inf_bitval

uint64_t const jau::double_iec559_positive_inf_bitval = 0x7ff0000000000000_u64
constexpr

Positive infinity bit-value of IEEE 754 (IEC 559) double double-point bit layout, i.e.

0x7ff0000000000000.

Definition at line 97 of file float_types.hpp.

◆ double_iec559_negative_inf_bitval

uint64_t const jau::double_iec559_negative_inf_bitval = 0xfff0000000000000_u64
constexpr

Negative infinity bit-value of IEEE 754 (IEC 559) double double-point bit layout, i.e.

0xfff0000000000000.

Definition at line 100 of file float_types.hpp.

◆ double_iec559_nan_bitval

uint64_t const jau::double_iec559_nan_bitval = 0x7ff8000000000000_u64
constexpr

NaN bit-value of IEEE 754 (IEC 559) double double-point bit layout, i.e.

0x7ff8000000000000.

Definition at line 103 of file float_types.hpp.