Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
internal::fp Class Reference

Public Member Functions

 fp (uint64_t f_val, int e_val)
template<typename Double>
 fp (Double d)
template<typename Double, FMT_ENABLE_IF(sizeof(Double)==sizeof(uint64_t))>
bool assign (Double d)
template<typename Double, FMT_ENABLE_IF(sizeof(Double) !=sizeof(uint64_t))>
bool assign (Double)
template<typename Double>
boundaries assign_with_boundaries (Double d)
template<typename Double>
boundaries assign_float_with_boundaries (Double d)

Public Attributes

significand_type f
int e

Static Public Attributes

static FMT_CONSTEXPR_DECL const int significand_size

Private Types

using significand_type = uint64_t

Static Private Attributes

static FMT_CONSTEXPR_DECL const int double_significand_size
static FMT_CONSTEXPR_DECL const uint64_t implicit_bit

Friends

template<int SHIFT>
fp normalize (fp value)

Constructor & Destructor Documentation

◆ fp() [1/3]

internal::fp::fp ( )
inline
449230: f(0), e(0) {}

◆ fp() [2/3]

internal::fp::fp ( uint64_t f_val,
int e_val )
inline
449231: f(f_val), e(e_val) {}

◆ fp() [3/3]

template<typename Double>
internal::fp::fp ( Double d)
inlineexplicit
449235{ assign(d); }

Member Function Documentation

◆ assign() [1/2]

template<typename Double, FMT_ENABLE_IF(sizeof(Double)==sizeof(uint64_t))>
bool internal::fp::assign ( Double d)
inline
449255 {
449256 // Assume double is in the format [sign][exponent][significand].
449257 using limits = std::numeric_limits<Double>;
449258 const int exponent_size =
449259 bits<Double>::value - double_significand_size - 1; // -1 for sign
449260 const uint64_t significand_mask = implicit_bit - 1;
449261 const uint64_t exponent_mask = (~0ULL >> 1) & ~significand_mask;
449262 const int exponent_bias = (1 << exponent_size) - limits::max_exponent - 1;
449263 auto u = bit_cast<uint64_t>(d);
449264 f = u & significand_mask;
449265 auto biased_e = (u & exponent_mask) >> double_significand_size;
449266 // Predecessor is closer if d is a normalized power of 2 (f == 0) other than
449267 // the smallest normalized number (biased_e > 1).
449268 bool is_predecessor_closer = f == 0 && biased_e > 1;
449269 if (biased_e != 0)
449270 f += implicit_bit;
449271 else
449272 biased_e = 1; // Subnormals use biased exponent 1 (min exponent).
449273 e = static_cast<int>(biased_e - exponent_bias - double_significand_size);
449274 return is_predecessor_closer;
449275 }
::uint64_t uint64_t

◆ assign() [2/2]

template<typename Double, FMT_ENABLE_IF(sizeof(Double) !=sizeof(uint64_t))>
bool internal::fp::assign ( Double )
inline
449278 {
449279 *this = fp();
449280 return false;
449281 }

◆ assign_with_boundaries()

template<typename Double>
boundaries internal::fp::assign_with_boundaries ( Double d)
inline
449287 {
449288 bool is_lower_closer = assign(d);
449289 fp lower =
449290 is_lower_closer ? fp((f << 2) - 1, e - 2) : fp((f << 1) - 1, e - 1);
449291 // 1 in normalize accounts for the exponent shift above.
449292 fp upper = normalize<1>(fp((f << 1) + 1, e - 1));
449293 lower.f <<= lower.e - upper.e;
449294 return boundaries{lower.f, upper.f};
449295 }

◆ assign_float_with_boundaries()

template<typename Double>
boundaries internal::fp::assign_float_with_boundaries ( Double d)
inline
449297 {
449298 assign(d);
449299 constexpr int min_normal_e = std::numeric_limits<float>::min_exponent -
449300 std::numeric_limits<double>::digits;
449301 significand_type half_ulp = 1 << (std::numeric_limits<double>::digits -
449302 std::numeric_limits<float>::digits - 1);
449303 if (min_normal_e > e) half_ulp <<= min_normal_e - e;
449304 fp upper = normalize<0>(fp(f + half_ulp, e));
449305 fp lower = fp(
449306 f - (half_ulp >> ((f == implicit_bit && e > min_normal_e) ? 1 : 0)), e);
449307 lower.f <<= lower.e - upper.e;
449308 return boundaries{lower.f, upper.f};
449309 }

◆ normalize

template<int SHIFT>
fp normalize ( fp value)
friend
449238 {
449239 // Handle subnormals.
449240 const auto shifted_implicit_bit = fp::implicit_bit << SHIFT;
449241 while ((value.f & shifted_implicit_bit) == 0) {
449242 value.f <<= 1;
449243 --value.e;
449244 }
449245 // Subtract 1 to account for hidden bit.
449246 const auto offset =
449247 fp::significand_size - fp::double_significand_size - SHIFT - 1;
449248 value.f <<= offset;
449249 value.e -= offset;
449250 return value;
449251 }

Member Data Documentation

◆ double_significand_size

FMT_CONSTEXPR_DECL const int internal::fp::double_significand_size
staticprivate
Initial value:
=
std::numeric_limits<double>::digits - 1

◆ implicit_bit

FMT_CONSTEXPR_DECL const uint64_t internal::fp::implicit_bit
staticprivate
Initial value:
=
1ULL << double_significand_size

◆ significand_size

FMT_CONSTEXPR_DECL const int internal::fp::significand_size
static
Initial value:
=
bits<significand_type>::value

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