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
duckdb::NumericHelper Class Reference

NumericHelper is a static class that holds helper functions for integers/doubles. More...

Public Member Functions

template<>
int UnsignedLength (uint8_t value)
 
template<>
int UnsignedLength (uint16_t value)
 
template<>
int UnsignedLength (uint32_t value)
 
template<>
int UnsignedLength (uint64_t value)
 
template<>
int UnsignedLength (hugeint_t value)
 
template<>
charFormatUnsigned (hugeint_t value, char *ptr)
 
template<>
std::string ToString (hugeint_t value)
 
template<>
std::string ToString (uhugeint_t value)
 
template<>
string_t FormatSigned (hugeint_t value, Vector &vector)
 

Static Public Member Functions

template<class T >
static int UnsignedLength (T value)
 
template<class SIGNED , class UNSIGNED >
static int SignedLength (SIGNED value)
 
template<class T >
static charFormatUnsigned (T value, char *ptr)
 
template<class T >
static string_t FormatSigned (T value, Vector &vector)
 
template<class T >
static std::string ToString (T value)
 

Static Public Attributes

static constexpr uint8_t CACHED_POWERS_OF_TEN = 19
 
static const int64_t POWERS_OF_TEN [CACHED_POWERS_OF_TEN]
 
static const double DOUBLE_POWERS_OF_TEN [40]
 

Detailed Description

NumericHelper is a static class that holds helper functions for integers/doubles.

Member Function Documentation

◆ SignedLength()

template<class SIGNED , class UNSIGNED >
static int duckdb::NumericHelper::SignedLength ( SIGNED  value)
inlinestatic
19721 {
19722 int sign = -(value < 0);
19723 UNSIGNED unsigned_value = UnsafeNumericCast<UNSIGNED>((value ^ sign) - sign);
19724 return UnsignedLength(unsigned_value) - sign;
19725 }

◆ FormatUnsigned()

template<class T >
static char * duckdb::NumericHelper::FormatUnsigned ( value,
char ptr 
)
inlinestatic
19729 {
19730 while (value >= 100) {
19731 // Integer division is slow so do it for a group of two digits instead
19732 // of for every digit. The idea comes from the talk by Alexandrescu
19733 // "Three Optimization Tips for C++".
19734 auto index = NumericCast<unsigned>((value % 100) * 2);
19735 value /= 100;
19736 *--ptr = duckdb_fmt::internal::data::digits[index + 1];
19737 *--ptr = duckdb_fmt::internal::data::digits[index];
19738 }
19739 if (value < 10) {
19740 *--ptr = NumericCast<char>('0' + value);
19741 return ptr;
19742 }
19743 auto index = NumericCast<unsigned>(value * 2);
19744 *--ptr = duckdb_fmt::internal::data::digits[index + 1];
19745 *--ptr = duckdb_fmt::internal::data::digits[index];
19746 return ptr;
19747 }
index

◆ FormatSigned()

template<class T >
static string_t duckdb::NumericHelper::FormatSigned ( value,
Vector vector 
)
inlinestatic
19750 {
19751 typedef typename MakeUnsigned<T>::type unsigned_t;
19752 int8_t sign = -(value < 0);
19753 unsigned_t unsigned_value = unsigned_t(value ^ T(sign)) + unsigned_t(AbsValue(sign));
19754 auto length = UnsafeNumericCast<idx_t>(UnsignedLength<unsigned_t>(unsigned_value) + AbsValue(sign));
19755 string_t result = StringVector::EmptyString(vector, length);
19756 auto dataptr = result.GetDataWriteable();
19757 auto endptr = dataptr + length;
19758 endptr = FormatUnsigned(unsigned_value, endptr);
19759 if (sign) {
19760 *--endptr = '-';
19761 }
19762 result.Finalize();
19763 return result;
19764 }
::int8_t int8_t
static DUCKDB_API string_t EmptyString(Vector &vector, idx_t len)

◆ ToString()

template<class T >
static std::string duckdb::NumericHelper::ToString ( value)
inlinestatic
19767 {
19768 return std::to_string(value);
19769 }

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