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

The Hugeint class contains static operations for the INT128 type. More...

#include <duckdb.hpp>

Collaboration diagram for duckdb::Hugeint:

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

static constexpr const charHUGEINT_MINIMUM_STRING = "-170141183460469231731687303715884105728"
 
static constexpr uint8_t CACHED_POWERS_OF_TEN = 39
 
static const hugeint_t POWERS_OF_TEN [CACHED_POWERS_OF_TEN]
 

Detailed Description

The Hugeint class contains static operations for the INT128 type.

Member Function Documentation

◆ Cast()

template<class T >
static T duckdb::Hugeint::Cast ( hugeint_t  input)
inlinestatic
14166 {
14167 T result = 0;
14168 TryCast(input, result);
14169 return result;
14170 }

◆ Convert()

template<class T >
static hugeint_t duckdb::Hugeint::Convert ( value)
inlinestatic
14176 {
14177 hugeint_t result;
14178 if (!TryConvert(value, result)) { // LCOV_EXCL_START
14179 throw OutOfRangeException(double(value), GetTypeId<T>(), GetTypeId<hugeint_t>());
14180 } // LCOV_EXCL_STOP
14181 return result;
14182 }

◆ NegateInPlace()

template<bool CHECK_OVERFLOW = true>
static void duckdb::Hugeint::NegateInPlace ( hugeint_t input)
inlinestatic
14187 {
14188 if (!TryNegate(input, input)) {
14189 throw OutOfRangeException("Negation of HUGEINT is out of range!");
14190 }
14191 }

◆ Negate()

template<bool CHECK_OVERFLOW = true>
static hugeint_t duckdb::Hugeint::Negate ( hugeint_t  input)
inlinestatic
14194 {
14195 NegateInPlace<CHECK_OVERFLOW>(input);
14196 return input;
14197 }

◆ Multiply()

template<bool CHECK_OVERFLOW = true>
static hugeint_t duckdb::Hugeint::Multiply ( hugeint_t  lhs,
hugeint_t  rhs 
)
inlinestatic
14202 {
14203 hugeint_t result;
14204 if (!TryMultiply(lhs, rhs, result)) {
14205 throw OutOfRangeException("Overflow in HUGEINT multiplication: %s * %s", lhs.ToString(), rhs.ToString());
14206 }
14207 return result;
14208 }

◆ Divide()

template<bool CHECK_OVERFLOW = true>
static hugeint_t duckdb::Hugeint::Divide ( hugeint_t  lhs,
hugeint_t  rhs 
)
inlinestatic
14213 {
14214 // No division by zero
14215 if (rhs == 0) {
14216 throw OutOfRangeException("Division of HUGEINT by zero: %s / %s", lhs.ToString(), rhs.ToString());
14217 }
14218
14219 // division only has one reason to overflow: MINIMUM / -1
14220 if (lhs == NumericLimits<hugeint_t>::Minimum() && rhs == -1) {
14221 throw OutOfRangeException("Overflow in HUGEINT division: %s / %s", lhs.ToString(), rhs.ToString());
14222 }
14223 return Divide<false>(lhs, rhs);
14224 }

◆ Modulo()

template<bool CHECK_OVERFLOW = true>
static hugeint_t duckdb::Hugeint::Modulo ( hugeint_t  lhs,
hugeint_t  rhs 
)
inlinestatic
14227 {
14228 // No division by zero
14229 if (rhs == 0) {
14230 throw OutOfRangeException("Modulo of HUGEINT by zero: %s %% %s", lhs.ToString(), rhs.ToString());
14231 }
14232
14233 // division only has one reason to overflow: MINIMUM / -1
14234 if (lhs == NumericLimits<hugeint_t>::Minimum() && rhs == -1) {
14235 throw OutOfRangeException("Overflow in HUGEINT modulo: %s %% %s", lhs.ToString(), rhs.ToString());
14236 }
14237 return Modulo<false>(lhs, rhs);
14238 }

◆ Add()

template<bool CHECK_OVERFLOW = true>
static hugeint_t duckdb::Hugeint::Add ( hugeint_t  lhs,
hugeint_t  rhs 
)
inlinestatic
14243 {
14244 if (!TryAddInPlace(lhs, rhs)) {
14245 throw OutOfRangeException("Overflow in HUGEINT addition: %s + %s", lhs.ToString(), rhs.ToString());
14246 }
14247 return lhs;
14248 }

◆ Subtract()

template<bool CHECK_OVERFLOW = true>
static hugeint_t duckdb::Hugeint::Subtract ( hugeint_t  lhs,
hugeint_t  rhs 
)
inlinestatic
14253 {
14254 if (!TrySubtractInPlace(lhs, rhs)) {
14255 throw OutOfRangeException("Underflow in HUGEINT subtraction: %s - %s", lhs.ToString(), rhs.ToString());
14256 }
14257 return lhs;
14258 }

◆ Equals()

static bool duckdb::Hugeint::Equals ( const hugeint_t lhs,
const hugeint_t rhs 
)
inlinestatic
14268 {
14269 bool lower_equals = lhs.lower == rhs.lower;
14270 bool upper_equals = lhs.upper == rhs.upper;
14271 return lower_equals && upper_equals;
14272 }

◆ NotEquals()

static bool duckdb::Hugeint::NotEquals ( const hugeint_t lhs,
const hugeint_t rhs 
)
inlinestatic
14274 {
14275 return !Equals(lhs, rhs);
14276 }

◆ GreaterThan()

static bool duckdb::Hugeint::GreaterThan ( const hugeint_t lhs,
const hugeint_t rhs 
)
inlinestatic
14278 {
14279 bool upper_bigger = lhs.upper > rhs.upper;
14280 bool upper_equal = lhs.upper == rhs.upper;
14281 bool lower_bigger = lhs.lower > rhs.lower;
14282 return upper_bigger || (upper_equal && lower_bigger);
14283 }

◆ GreaterThanEquals()

static bool duckdb::Hugeint::GreaterThanEquals ( const hugeint_t lhs,
const hugeint_t rhs 
)
inlinestatic
14285 {
14286 bool upper_bigger = lhs.upper > rhs.upper;
14287 bool upper_equal = lhs.upper == rhs.upper;
14288 bool lower_bigger_equals = lhs.lower >= rhs.lower;
14289 return upper_bigger || (upper_equal && lower_bigger_equals);
14290 }

◆ LessThan()

static bool duckdb::Hugeint::LessThan ( const hugeint_t lhs,
const hugeint_t rhs 
)
inlinestatic
14292 {
14293 bool upper_smaller = lhs.upper < rhs.upper;
14294 bool upper_equal = lhs.upper == rhs.upper;
14295 bool lower_smaller = lhs.lower < rhs.lower;
14296 return upper_smaller || (upper_equal && lower_smaller);
14297 }

◆ LessThanEquals()

static bool duckdb::Hugeint::LessThanEquals ( const hugeint_t lhs,
const hugeint_t rhs 
)
inlinestatic
14299 {
14300 bool upper_smaller = lhs.upper < rhs.upper;
14301 bool upper_equal = lhs.upper == rhs.upper;
14302 bool lower_smaller_equals = lhs.lower <= rhs.lower;
14303 return upper_smaller || (upper_equal && lower_smaller_equals);
14304 }

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