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::IntegerDecimalCastOperation Struct Reference
Inheritance diagram for duckdb::IntegerDecimalCastOperation:
Collaboration diagram for duckdb::IntegerDecimalCastOperation:

Static Public Member Functions

template<class T , bool NEGATIVE>
static bool HandleExponent (T &state, int16_t exponent)
 
template<class T , bool NEGATIVE, bool ALLOW_EXPONENT>
static bool HandleDecimal (T &state, uint8_t digit)
 
template<class T , bool NEGATIVE>
static bool Finalize (T &state)
 
- Static Public Member Functions inherited from duckdb::IntegerCastOperation
template<class T , bool NEGATIVE>
static bool HandleDigit (T &state, uint8_t digit)
 
template<class T , bool NEGATIVE>
static bool HandleHexDigit (T &state, uint8_t digit)
 
template<class T , bool NEGATIVE>
static bool HandleBinaryDigit (T &state, uint8_t digit)
 
template<class T , bool NEGATIVE>
static bool HandleExponent (T &state, int16_t exponent)
 
template<class T , bool NEGATIVE, bool ALLOW_EXPONENT>
static bool HandleDecimal (T &state, uint8_t digit)
 
template<class T , bool NEGATIVE>
static bool Finalize (T &state)
 

Member Function Documentation

◆ HandleExponent()

template<class T , bool NEGATIVE>
static bool duckdb::IntegerDecimalCastOperation::HandleExponent ( T &  state,
int16_t  exponent 
)
inlinestatic
54248 {
54249 using store_t = typename T::StoreType;
54250
54251 int16_t e = exponent;
54252 // Negative Exponent
54253 if (e < 0) {
54254 while (e++ < 0) {
54255 state.decimal = state.result % 10;
54256 state.result /= 10;
54257 if (state.result == 0 && state.decimal == 0) {
54258 break;
54259 }
54260 }
54261 if (state.decimal < 0) {
54262 state.decimal = -state.decimal;
54263 }
54264 state.decimal_digits = 1;
54265 return Finalize<T, NEGATIVE>(state);
54266 }
54267
54268 // Positive Exponent
54269 while (state.result != 0 && e-- > 0) {
54270 if (!TryMultiplyOperator::Operation(state.result, (store_t)10, state.result)) {
54271 return false;
54272 }
54273 }
54274
54275 if (state.decimal == 0) {
54276 return Finalize<T, NEGATIVE>(state);
54277 }
54278
54279 // Handle decimals
54280 e = UnsafeNumericCast<int16_t>(exponent - state.decimal_digits);
54281 store_t remainder = 0;
54282 if (e < 0) {
54283 if (static_cast<uint16_t>(-e) <= NumericLimits<store_t>::Digits()) {
54284 store_t power = 1;
54285 while (e++ < 0) {
54286 power *= 10;
54287 }
54288 remainder = state.decimal % power;
54289 state.decimal /= power;
54290 } else {
54291 state.decimal = 0;
54292 }
54293 } else {
54294 while (e-- > 0) {
54295 if (!TryMultiplyOperator::Operation(state.decimal, (store_t)10, state.decimal)) {
54296 return false;
54297 }
54298 }
54299 }
54300
54301 state.decimal_digits -= exponent;
54302
54303 if (NEGATIVE) {
54304 if (!TrySubtractOperator::Operation(state.result, state.decimal, state.result)) {
54305 return false;
54306 }
54307 } else if (!TryAddOperator::Operation(state.result, state.decimal, state.result)) {
54308 return false;
54309 }
54310 state.decimal = remainder;
54311 return Finalize<T, NEGATIVE>(state);
54312 }
Quat< T > power(const Quat< T > &q, const Quat< T > &p, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
::uint16_t uint16_t
::int16_t int16_t

◆ HandleDecimal()

template<class T , bool NEGATIVE, bool ALLOW_EXPONENT>
static bool duckdb::IntegerDecimalCastOperation::HandleDecimal ( T &  state,
uint8_t  digit 
)
inlinestatic
54315 {
54316 using store_t = typename T::StoreType;
54317 if (DUCKDB_UNLIKELY(state.decimal > (NumericLimits<store_t>::Maximum() - digit) / 10)) {
54318 // Simply ignore any more decimals
54319 return true;
54320 }
54321 state.decimal_digits++;
54322 state.decimal = state.decimal * 10 + digit;
54323 return true;
54324 }

◆ Finalize()

template<class T , bool NEGATIVE>
static bool duckdb::IntegerDecimalCastOperation::Finalize ( T &  state)
inlinestatic
54327 {
54328 using result_t = typename T::ResultType;
54329 using store_t = typename T::StoreType;
54330
54331 result_t tmp;
54332 if (!TryCast::Operation<store_t, result_t>(state.result, tmp)) {
54333 return false;
54334 }
54335
54336 while (state.decimal > 10) {
54337 state.decimal /= 10;
54338 state.decimal_digits--;
54339 }
54340
54341 bool success = true;
54342 if (state.decimal_digits == 1 && state.decimal >= 5) {
54343 if (NEGATIVE) {
54344 success = TrySubtractOperator::Operation(tmp, (result_t)1, tmp);
54345 } else {
54346 success = TryAddOperator::Operation(tmp, (result_t)1, tmp);
54347 }
54348 }
54349 state.result = tmp;
54350 return success;
54351 }

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