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::DecimalToString Struct Reference

Public Member Functions

template<>
int DecimalLength (hugeint_t value, uint8_t width, uint8_t scale)
 
template<>
string_t Format (hugeint_t value, uint8_t width, uint8_t scale, Vector &vector)
 
template<>
void FormatDecimal (hugeint_t value, uint8_t width, uint8_t scale, char *dst, idx_t len)
 

Static Public Member Functions

template<class SIGNED >
static int DecimalLength (SIGNED value, uint8_t width, uint8_t scale)
 
template<class SIGNED >
static void FormatDecimal (SIGNED value, uint8_t width, uint8_t scale, char *dst, idx_t len)
 
template<class SIGNED >
static string_t Format (SIGNED value, uint8_t width, uint8_t scale, Vector &vector)
 

Member Function Documentation

◆ DecimalLength()

template<class SIGNED >
static int duckdb::DecimalToString::DecimalLength ( SIGNED  value,
uint8_t  width,
uint8_t  scale 
)
inlinestatic
19797 {
19798 using UNSIGNED = typename MakeUnsigned<SIGNED>::type;
19799 if (scale == 0) {
19800 // scale is 0: regular number
19801 return NumericHelper::SignedLength<SIGNED, UNSIGNED>(value);
19802 }
19803 // length is max of either:
19804 // scale + 2 OR
19805 // integer length + 1
19806 // scale + 2 happens when the number is in the range of (-1, 1)
19807 // in that case we print "0.XXX", which is the scale, plus "0." (2 chars)
19808 // integer length + 1 happens when the number is outside of that range
19809 // in that case we print the integer number, but with one extra character ('.')
19810 auto extra_characters = width > scale ? 2 : 1;
19811 return MaxValue(scale + extra_characters + (value < 0 ? 1 : 0),
19812 NumericHelper::SignedLength<SIGNED, UNSIGNED>(value) + 1);
19813 }
void scale(cv::Mat &mat, const cv::Mat &range, const T min, const T max)

◆ FormatDecimal()

template<class SIGNED >
static void duckdb::DecimalToString::FormatDecimal ( SIGNED  value,
uint8_t  width,
uint8_t  scale,
char dst,
idx_t  len 
)
inlinestatic
19816 {
19817 using UNSIGNED = typename MakeUnsigned<SIGNED>::type;
19818 char *end = dst + len;
19819 if (value < 0) {
19820 value = -value;
19821 *dst = '-';
19822 }
19823 if (scale == 0) {
19824 NumericHelper::FormatUnsigned<UNSIGNED>(UnsafeNumericCast<UNSIGNED>(value), end);
19825 return;
19826 }
19827 // we write two numbers:
19828 // the numbers BEFORE the decimal (major)
19829 // and the numbers AFTER the decimal (minor)
19830 auto minor =
19831 UnsafeNumericCast<UNSIGNED>(value) % UnsafeNumericCast<UNSIGNED>(NumericHelper::POWERS_OF_TEN[scale]);
19832 auto major =
19833 UnsafeNumericCast<UNSIGNED>(value) / UnsafeNumericCast<UNSIGNED>(NumericHelper::POWERS_OF_TEN[scale]);
19834 // write the number after the decimal
19835 dst = NumericHelper::FormatUnsigned<UNSIGNED>(UnsafeNumericCast<UNSIGNED>(minor), end);
19836 // (optionally) pad with zeros and add the decimal point
19837 while (dst > (end - scale)) {
19838 *--dst = '0';
19839 }
19840 *--dst = '.';
19841 // now write the part before the decimal
19842 D_ASSERT(width > scale || major == 0);
19843 if (width > scale) {
19844 // there are numbers after the comma
19845 dst = NumericHelper::FormatUnsigned<UNSIGNED>(UnsafeNumericCast<UNSIGNED>(major), dst);
19846 }
19847 }

◆ Format()

template<class SIGNED >
static string_t duckdb::DecimalToString::Format ( SIGNED  value,
uint8_t  width,
uint8_t  scale,
Vector vector 
)
inlinestatic
19850 {
19851 int len = DecimalLength<SIGNED>(value, width, scale);
19852 string_t result = StringVector::EmptyString(vector, NumericCast<size_t>(len));
19853 FormatDecimal<SIGNED>(value, width, scale, result.GetDataWriteable(), UnsafeNumericCast<idx_t>(len));
19854 result.Finalize();
19855 return result;
19856 }
static DUCKDB_API string_t EmptyString(Vector &vector, idx_t len)

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