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::Uhugeint Class Reference

The uhugeint class contains static operations for the UINT128 type. More...

#include <duckdb.hpp>

Collaboration diagram for duckdb::Uhugeint:

Public Member Functions

template<>
DUCKDB_API bool TryCast (uhugeint_t input, int8_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, int16_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, int32_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, int64_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, uint8_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, uint16_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, uint32_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, uint64_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, hugeint_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, uhugeint_t &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, float &result)
 
template<>
DUCKDB_API bool TryCast (uhugeint_t input, double &result)
 
template<>
bool TryConvert (int8_t value, uhugeint_t &result)
 
template<>
bool TryConvert (int16_t value, uhugeint_t &result)
 
template<>
bool TryConvert (int32_t value, uhugeint_t &result)
 
template<>
bool TryConvert (int64_t value, uhugeint_t &result)
 
template<>
bool TryConvert (uint8_t value, uhugeint_t &result)
 
template<>
bool TryConvert (uint16_t value, uhugeint_t &result)
 
template<>
bool TryConvert (uint32_t value, uhugeint_t &result)
 
template<>
bool TryConvert (uint64_t value, uhugeint_t &result)
 
template<>
bool TryConvert (float value, uhugeint_t &result)
 
template<>
bool TryConvert (double value, uhugeint_t &result)
 
template<>
bool TryConvert (long double value, uhugeint_t &result)
 
template<>
bool TryConvert (const char *value, uhugeint_t &result)
 

Static Public Member Functions

static string ToString (uhugeint_t input)
 Convert a uhugeint object to a string.
 
template<class T >
static DUCKDB_API bool TryCast (uhugeint_t input, T &result)
 
template<class T >
staticCast (uhugeint_t input)
 
template<class T >
static bool TryConvert (T value, uhugeint_t &result)
 
template<class T >
static uhugeint_t Convert (T value)
 
static bool TryNegate (uhugeint_t input, uhugeint_t &result)
 
template<bool CHECK_OVERFLOW = true>
static void NegateInPlace (uhugeint_t &input)
 
template<bool CHECK_OVERFLOW = true>
static uhugeint_t Negate (uhugeint_t input)
 
static bool TryMultiply (uhugeint_t lhs, uhugeint_t rhs, uhugeint_t &result)
 
template<bool CHECK_OVERFLOW = true>
static uhugeint_t Multiply (uhugeint_t lhs, uhugeint_t rhs)
 
static bool TryDivMod (uhugeint_t lhs, uhugeint_t rhs, uhugeint_t &result, uhugeint_t &remainder)
 
template<bool CHECK_OVERFLOW = true>
static uhugeint_t Divide (uhugeint_t lhs, uhugeint_t rhs)
 
template<bool CHECK_OVERFLOW = true>
static uhugeint_t Modulo (uhugeint_t lhs, uhugeint_t rhs)
 
static bool TryAddInPlace (uhugeint_t &lhs, uhugeint_t rhs)
 
template<bool CHECK_OVERFLOW = true>
static uhugeint_t Add (uhugeint_t lhs, uhugeint_t rhs)
 
static bool TrySubtractInPlace (uhugeint_t &lhs, uhugeint_t rhs)
 
template<bool CHECK_OVERFLOW = true>
static uhugeint_t Subtract (uhugeint_t lhs, uhugeint_t rhs)
 
static uhugeint_t DivMod (uhugeint_t lhs, uhugeint_t rhs, uhugeint_t &remainder)
 
static int Sign (hugeint_t n)
 
static hugeint_t Abs (hugeint_t n)
 
static bool Equals (uhugeint_t lhs, uhugeint_t rhs)
 
static bool NotEquals (uhugeint_t lhs, uhugeint_t rhs)
 
static bool GreaterThan (uhugeint_t lhs, uhugeint_t rhs)
 
static bool GreaterThanEquals (uhugeint_t lhs, uhugeint_t rhs)
 
static bool LessThan (uhugeint_t lhs, uhugeint_t rhs)
 
static bool LessThanEquals (uhugeint_t lhs, uhugeint_t rhs)
 

Static Public Attributes

static constexpr uint8_t CACHED_POWERS_OF_TEN = 39
 
static const uhugeint_t POWERS_OF_TEN [CACHED_POWERS_OF_TEN]
 

Detailed Description

The uhugeint class contains static operations for the UINT128 type.

Member Function Documentation

◆ Cast()

template<class T >
static T duckdb::Uhugeint::Cast ( uhugeint_t  input)
inlinestatic
52506 {
52507 T result = 0;
52508 TryCast(input, result);
52509 return result;
52510 }

◆ Convert()

template<class T >
static uhugeint_t duckdb::Uhugeint::Convert ( value)
inlinestatic
52516 {
52517 uhugeint_t result;
52518 if (!TryConvert(value, result)) { // LCOV_EXCL_START
52519 throw OutOfRangeException(double(value), GetTypeId<T>(), GetTypeId<uhugeint_t>());
52520 } // LCOV_EXCL_STOP
52521 return result;
52522 }

◆ NegateInPlace()

template<bool CHECK_OVERFLOW = true>
static void duckdb::Uhugeint::NegateInPlace ( uhugeint_t input)
inlinestatic
52529 {
52530 if (!TryNegate(input, input)) {
52531 throw OutOfRangeException("UHUGEINT is out of range");
52532 }
52533 }

◆ Negate()

template<bool CHECK_OVERFLOW = true>
static uhugeint_t duckdb::Uhugeint::Negate ( uhugeint_t  input)
inlinestatic
52536 {
52537 NegateInPlace<CHECK_OVERFLOW>(input);
52538 return input;
52539 }

◆ Multiply()

template<bool CHECK_OVERFLOW = true>
static uhugeint_t duckdb::Uhugeint::Multiply ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52544 {
52545 uhugeint_t result;
52546 if (!TryMultiply(lhs, rhs, result)) {
52547 throw OutOfRangeException("Overflow in UHUGEINT multiplication: %s * %s", lhs.ToString(), rhs.ToString());
52548 }
52549 return result;
52550 }

◆ Divide()

template<bool CHECK_OVERFLOW = true>
static uhugeint_t duckdb::Uhugeint::Divide ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52555 {
52556 // division between two same-size unsigned integers can only go wrong with division by zero
52557 if (rhs == 0) {
52558 throw OutOfRangeException("Division of UHUGEINT by zero: %s / %s", lhs.ToString(), rhs.ToString());
52559 }
52560 return Divide<false>(lhs, rhs);
52561 }

◆ Modulo()

template<bool CHECK_OVERFLOW = true>
static uhugeint_t duckdb::Uhugeint::Modulo ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52564 {
52565 if (rhs == 0) {
52566 throw OutOfRangeException("Modulo of UHUGEINT by zero: %s %% %s", lhs.ToString(), rhs.ToString());
52567 }
52568 return Modulo<false>(lhs, rhs);
52569 }

◆ Add()

template<bool CHECK_OVERFLOW = true>
static uhugeint_t duckdb::Uhugeint::Add ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52574 {
52575 if (!TryAddInPlace(lhs, rhs)) {
52576 throw OutOfRangeException("Overflow in UHUGEINT addition: %s + %s", lhs.ToString(), rhs.ToString());
52577 }
52578 return lhs;
52579 }

◆ Subtract()

template<bool CHECK_OVERFLOW = true>
static uhugeint_t duckdb::Uhugeint::Subtract ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52584 {
52585 if (!TrySubtractInPlace(lhs, rhs)) {
52586 throw OutOfRangeException("Underflow in HUGEINT subtraction: %s - %s", lhs.ToString(), rhs.ToString());
52587 }
52588 return lhs;
52589 }

◆ Equals()

static bool duckdb::Uhugeint::Equals ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52598 {
52599 bool lower_equals = lhs.lower == rhs.lower;
52600 bool upper_equals = lhs.upper == rhs.upper;
52601 return lower_equals && upper_equals;
52602 }

◆ NotEquals()

static bool duckdb::Uhugeint::NotEquals ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52604 {
52605 return !Equals(lhs, rhs);
52606 }

◆ GreaterThan()

static bool duckdb::Uhugeint::GreaterThan ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52608 {
52609 bool upper_bigger = lhs.upper > rhs.upper;
52610 bool upper_equal = lhs.upper == rhs.upper;
52611 bool lower_bigger = lhs.lower > rhs.lower;
52612 return upper_bigger || (upper_equal && lower_bigger);
52613 }

◆ GreaterThanEquals()

static bool duckdb::Uhugeint::GreaterThanEquals ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52615 {
52616 bool upper_bigger = lhs.upper > rhs.upper;
52617 bool upper_equal = lhs.upper == rhs.upper;
52618 bool lower_bigger_equals = lhs.lower >= rhs.lower;
52619 return upper_bigger || (upper_equal && lower_bigger_equals);
52620 }

◆ LessThan()

static bool duckdb::Uhugeint::LessThan ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52622 {
52623 bool upper_smaller = lhs.upper < rhs.upper;
52624 bool upper_equal = lhs.upper == rhs.upper;
52625 bool lower_smaller = lhs.lower < rhs.lower;
52626 return upper_smaller || (upper_equal && lower_smaller);
52627 }

◆ LessThanEquals()

static bool duckdb::Uhugeint::LessThanEquals ( uhugeint_t  lhs,
uhugeint_t  rhs 
)
inlinestatic
52629 {
52630 bool upper_smaller = lhs.upper < rhs.upper;
52631 bool upper_equal = lhs.upper == rhs.upper;
52632 bool lower_smaller_equals = lhs.lower <= rhs.lower;
52633 return upper_smaller || (upper_equal && lower_smaller_equals);
52634 }

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