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

The Bignum class is a static class that holds helper functions for the Bignum type. More...

Static Public Member Functions

static DUCKDB_API void Verify (const bignum_t &input)
static DUCKDB_API void SetHeader (char *blob, uint64_t number_of_bytes, bool is_negative)
static DUCKDB_API bignum_t InitializeBignumZero (Vector &result)
 Initializes and returns a blob with value 0, allocated in Vector& result.
static DUCKDB_API string InitializeBignumZero ()
static DUCKDB_API BoundCastInfo NumericToBignumCastSwitch (const LogicalType &source)
 Switch Case of To Bignum Convertion.
static DUCKDB_API bool VarcharFormatting (const string_t &value, idx_t &start_pos, idx_t &end_pos, bool &is_negative, bool &is_zero)
static DUCKDB_API int CharToDigit (char c)
 Converts a char to a Digit.
static DUCKDB_API char DigitToChar (int digit)
 Converts a Digit to a char.
static DUCKDB_API void GetByteArray (vector< uint8_t > &byte_array, bool &is_negative, const string_t &blob)
 Function to convert a string_t into a vector of bytes.
static DUCKDB_API string FromByteArray (uint8_t *data, idx_t size, bool is_negative)
 Function to create a BIGNUM blob from a byte array containing the absolute value, plus an is_negative bool.
static DUCKDB_API string BignumToVarchar (const bignum_t &blob)
 Function to convert BIGNUM blob to a VARCHAR.
static DUCKDB_API string VarcharToBignum (const string_t &value)
 Function to convert Varchar to BIGNUM blob.
static DUCKDB_API bool BignumToDouble (const bignum_t &blob, double &result, bool &strict)
 --------------------------------— Double Cast --------------------------------— //
template<class T>
static bool BignumToInt (const bignum_t &blob, T &result, bool &strict)

Static Public Attributes

static DUCKDB_API constexpr uint32_t MAX_DATA_SIZE = 8388607
static DUCKDB_API constexpr uint8_t BIGNUM_HEADER_SIZE = 3
 Header size of a Bignum is always 3 bytes.
static DUCKDB_API constexpr uint8_t DECIMAL_SHIFT = 9
 Max(e such that 10**e fits in a digit_t).
static DUCKDB_API constexpr digit_t DECIMAL_BASE = 1000000000
 10 ** DECIMAL_SHIFT
static DUCKDB_API constexpr uint8_t DIGIT_BYTES = sizeof(digit_t)
 Bytes of a digit_t.
static DUCKDB_API constexpr uint8_t DIGIT_BITS = DIGIT_BYTES * 8
 Bits of a digit_t.

Detailed Description

The Bignum class is a static class that holds helper functions for the Bignum type.

Member Function Documentation

◆ Verify()

void duckdb::Bignum::Verify ( const bignum_t & input)
static

Verifies if a Bignum is valid. i.e., if it has 3 header bytes. The header correctly represents the number of data bytes, and the data bytes has no leading zero bytes.

112334 {
112335#ifdef DEBUG
112336 // Size must be >= 4
112337 idx_t bignum_bytes = input.data.GetSize();
112338 if (bignum_bytes < 4) {
112339 throw InternalException("Bignum number of bytes is invalid, current number of bytes is %d", bignum_bytes);
112340 }
112341 // Bytes in header must quantify the number of data bytes
112342 auto bignum_ptr = input.data.GetData();
112343 bool is_negative = (bignum_ptr[0] & 0x80) == 0;
112344 uint32_t number_of_bytes = 0;
112345 if (bignum_bytes == 4 && is_negative) {
112346 // There is only one invalid value, which is -0
112347 if (bignum_ptr[3] == static_cast<char>(0xFF)) {
112348 throw InternalException("Bignum value -0 is not allowed in the Bignum specification.");
112349 }
112350 }
112351
112352 char mask = 0x7F;
112353 if (is_negative) {
112354 number_of_bytes |= static_cast<uint32_t>(~bignum_ptr[0] & mask) << 16 & 0xFF0000;
112355 number_of_bytes |= static_cast<uint32_t>(~bignum_ptr[1]) << 8 & 0xFF00;
112356 ;
112357 number_of_bytes |= static_cast<uint32_t>(~bignum_ptr[2]) & 0xFF;
112358 } else {
112359 number_of_bytes |= static_cast<uint32_t>(bignum_ptr[0] & mask) << 16 & 0xFF0000;
112360 number_of_bytes |= static_cast<uint32_t>(bignum_ptr[1]) << 8 & 0xFF00;
112361 number_of_bytes |= static_cast<uint32_t>(bignum_ptr[2]) & 0xFF;
112362 }
112363 if (number_of_bytes != bignum_bytes - 3) {
112364 throw InternalException("The number of bytes set in the Bignum header: %d bytes. Does not "
112365 "match the number of bytes encountered as the bignum data: %d bytes.",
112366 number_of_bytes, bignum_bytes - 3);
112367 }
112368 // No bytes between 4 and end can be 0, unless total size == 4
112369 if (bignum_bytes > 4) {
112370 if (is_negative) {
112371 if (static_cast<data_t>(~bignum_ptr[3]) == 0) {
112372 throw InternalException("Invalid top data bytes set to 0 for BIGNUM values");
112373 }
112374 } else {
112375 if (bignum_ptr[3] == 0) {
112376 throw InternalException("Invalid top data bytes set to 0 for BIGNUM values");
112377 }
112378 }
112379 }
112380#endif
112381}
GMat mask(const GMat &src, const GMat &mask)
::uint32_t uint32_t
uint8_t data_t
data pointers
Definition duckdb.hpp:246
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ SetHeader()

void duckdb::Bignum::SetHeader ( char * blob,
uint64_t number_of_bytes,
bool is_negative )
static

Sets the header of a bignum (i.e., char* blob), depending on the number of bytes that bignum needs and if it's a negative number

112382 {
112383 uint32_t header = static_cast<uint32_t>(number_of_bytes);
112384 // Set MSBit of 3rd byte
112385 header |= 0x00800000;
112386 if (is_negative) {
112387 header = ~header;
112388 }
112389 // we ignore MSByte of header.
112390 // write the 3 bytes to blob.
112391 blob[0] = static_cast<char>(header >> 16);
112392 blob[1] = static_cast<char>(header >> 8 & 0xFF);
112393 blob[2] = static_cast<char>(header & 0xFF);
112394}
Here is the caller graph for this function:

◆ InitializeBignumZero() [1/2]

bignum_t duckdb::Bignum::InitializeBignumZero ( Vector & result)
static

Initializes and returns a blob with value 0, allocated in Vector& result.

112397 {
112398 uint32_t blob_size = 1 + BIGNUM_HEADER_SIZE;
112399 auto blob = StringVector::EmptyString(result, blob_size);
112400 auto writable_blob = blob.GetDataWriteable();
112401 SetHeader(writable_blob, 1, false);
112402 writable_blob[3] = 0;
112403 blob.Finalize();
112404 const bignum_t result_bignum(blob);
112405 return result_bignum;
112406}
static DUCKDB_API void SetHeader(char *blob, uint64_t number_of_bytes, bool is_negative)
Definition duckdb.cpp:112382
static DUCKDB_API constexpr uint8_t BIGNUM_HEADER_SIZE
Header size of a Bignum is always 3 bytes.
Definition duckdb.cpp:46515
static DUCKDB_API string_t EmptyString(Vector &vector, idx_t len)
Definition duckdb.cpp:137942
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeBignumZero() [2/2]

string duckdb::Bignum::InitializeBignumZero ( )
static
112408 {
112409 uint32_t blob_size = 1 + BIGNUM_HEADER_SIZE;
112410 string result(blob_size, '0');
112411 SetHeader(&result[0], 1, false);
112412 result[3] = 0;
112413 return result;
112414}

◆ NumericToBignumCastSwitch()

BoundCastInfo duckdb::Bignum::NumericToBignumCastSwitch ( const LogicalType & source)
static

Switch Case of To Bignum Convertion.

212830 {
212831 // now switch on the result type
212832 switch (source.id()) {
212833 case LogicalTypeId::TINYINT:
212834 return BoundCastInfo(&VectorCastHelpers::StringCast<int8_t, IntCastToBignum, bignum_t>);
212835 case LogicalTypeId::UTINYINT:
212836 return BoundCastInfo(&VectorCastHelpers::StringCast<uint8_t, IntCastToBignum, bignum_t>);
212837 case LogicalTypeId::SMALLINT:
212838 return BoundCastInfo(&VectorCastHelpers::StringCast<int16_t, IntCastToBignum, bignum_t>);
212839 case LogicalTypeId::USMALLINT:
212840 return BoundCastInfo(&VectorCastHelpers::StringCast<uint16_t, IntCastToBignum, bignum_t>);
212841 case LogicalTypeId::INTEGER:
212842 return BoundCastInfo(&VectorCastHelpers::StringCast<int32_t, IntCastToBignum, bignum_t>);
212843 case LogicalTypeId::UINTEGER:
212844 return BoundCastInfo(&VectorCastHelpers::StringCast<uint32_t, IntCastToBignum, bignum_t>);
212845 case LogicalTypeId::BIGINT:
212846 return BoundCastInfo(&VectorCastHelpers::StringCast<int64_t, IntCastToBignum, bignum_t>);
212847 case LogicalTypeId::UBIGINT:
212848 return BoundCastInfo(&VectorCastHelpers::StringCast<uint64_t, IntCastToBignum, bignum_t>);
212849 case LogicalTypeId::UHUGEINT:
212850 return BoundCastInfo(&VectorCastHelpers::StringCast<uhugeint_t, HugeintCastToBignum, bignum_t>);
212851 case LogicalTypeId::FLOAT:
212852 return BoundCastInfo(&VectorCastHelpers::TryCastStringLoop<float, bignum_t, TryCastToBignum>);
212853 case LogicalTypeId::DOUBLE:
212854 return BoundCastInfo(&VectorCastHelpers::TryCastStringLoop<double, bignum_t, TryCastToBignum>);
212855 case LogicalTypeId::HUGEINT:
212856 return BoundCastInfo(&VectorCastHelpers::StringCast<hugeint_t, HugeintCastToBignum, bignum_t>);
212857 case LogicalTypeId::DECIMAL:
212858 default:
212859 return DefaultCasts::TryVectorNullCast;
212860 }
212861}

◆ VarcharFormatting()

bool duckdb::Bignum::VarcharFormatting ( const string_t & value,
idx_t & start_pos,
idx_t & end_pos,
bool & is_negative,
bool & is_zero )
static

--------------------------------— Varchar Cast --------------------------------— // Function to prepare a varchar for conversion. We trim zero's, check for negative values, and what-not Returns false if this is an invalid varchar

112427 {
112428 // If it's empty we error
112429 if (value.Empty()) {
112430 return false;
112431 }
112432 start_pos = 0;
112433 is_zero = false;
112434
112435 auto int_value_char = value.GetData();
112436 end_pos = value.GetSize();
112437
112438 // If first character is -, we have a negative number, if + we have a + number
112439 is_negative = int_value_char[0] == '-';
112440 if (is_negative) {
112441 start_pos++;
112442 }
112443 if (int_value_char[0] == '+') {
112444 start_pos++;
112445 }
112446 // Now lets trim 0s
112447 bool at_least_one_zero = false;
112448 while (start_pos < end_pos && int_value_char[start_pos] == '0') {
112449 start_pos++;
112450 at_least_one_zero = true;
112451 }
112452 if (start_pos == end_pos) {
112453 if (at_least_one_zero) {
112454 // This is a 0 value
112455 is_zero = true;
112456 return true;
112457 }
112458 // This is either a '+' or '-'. Hence, invalid.
112459 return false;
112460 }
112461 idx_t cur_pos = start_pos;
112462 // Verify all is numeric
112463 while (cur_pos < end_pos && std::isdigit(int_value_char[cur_pos])) {
112464 cur_pos++;
112465 }
112466 if (cur_pos < end_pos) {
112467 idx_t possible_end = cur_pos;
112468 // Oh oh, this is not a digit, if it's a . we might be fine, otherwise, this is invalid.
112469 if (int_value_char[cur_pos] == '.') {
112470 cur_pos++;
112471 } else {
112472 return false;
112473 }
112474
112475 while (cur_pos < end_pos) {
112476 if (std::isdigit(int_value_char[cur_pos])) {
112477 cur_pos++;
112478 } else {
112479 // By now we can only have numbers, otherwise this is invalid.
112480 return false;
112481 }
112482 }
112483 // Floor cast this boy
112484 end_pos = possible_end;
112485 }
112486 return true;
112487}
Here is the caller graph for this function:

◆ CharToDigit()

int duckdb::Bignum::CharToDigit ( char c)
static

Converts a char to a Digit.

112416 {
112417 return c - '0';
112418}

◆ DigitToChar()

char duckdb::Bignum::DigitToChar ( int digit)
static

Converts a Digit to a char.

112420 {
112421 // FIXME: this would be the proper solution:
112422 // return UnsafeNumericCast<char>(digit + '0');
112423 return static_cast<char>(digit + '0');
112424}
Here is the caller graph for this function:

◆ GetByteArray()

void duckdb::Bignum::GetByteArray ( vector< uint8_t > & byte_array,
bool & is_negative,
const string_t & blob )
static

Function to convert a string_t into a vector of bytes.

112489 {
112490 if (blob.GetSize() < 4) {
112491 throw InvalidInputException("Invalid blob size.");
112492 }
112493 auto blob_ptr = blob.GetData();
112494
112495 // Determine if the number is negative
112496 is_negative = (blob_ptr[0] & 0x80) == 0;
112497 byte_array.reserve(blob.GetSize() - 3);
112498 if (is_negative) {
112499 for (idx_t i = 3; i < blob.GetSize(); i++) {
112500 byte_array.push_back(static_cast<uint8_t>(~blob_ptr[i]));
112501 }
112502 } else {
112503 for (idx_t i = 3; i < blob.GetSize(); i++) {
112504 byte_array.push_back(static_cast<uint8_t>(blob_ptr[i]));
112505 }
112506 }
112507}
::uint8_t uint8_t
Here is the caller graph for this function:

◆ FromByteArray()

string duckdb::Bignum::FromByteArray ( uint8_t * data,
idx_t size,
bool is_negative )
static

Function to create a BIGNUM blob from a byte array containing the absolute value, plus an is_negative bool.

112509 {
112510 string result(BIGNUM_HEADER_SIZE + size, '0');
112511 SetHeader(&result[0], size, is_negative);
112512 uint8_t *result_data = reinterpret_cast<uint8_t *>(&result[BIGNUM_HEADER_SIZE]);
112513 if (is_negative) {
112514 for (idx_t i = 0; i < size; i++) {
112515 result_data[i] = ~data[i];
112516 }
112517 } else {
112518 for (idx_t i = 0; i < size; i++) {
112519 result_data[i] = data[i];
112520 }
112521 }
112522 return result;
112523}
GOpaque< Size > size(const GMat &src)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BignumToVarchar()

string duckdb::Bignum::BignumToVarchar ( const bignum_t & blob)
static

Function to convert BIGNUM blob to a VARCHAR.

112526 {
112527 string decimal_string;
112528 vector<uint8_t> byte_array;
112529 bool is_negative;
112530 GetByteArray(byte_array, is_negative, blob.data);
112531 vector<digit_t> digits;
112532 // Rounding byte_array to digit_bytes multiple size, so that we can process every digit_bytes bytes
112533 // at a time without if check in the for loop
112534 idx_t padding_size = (-byte_array.size()) & (DIGIT_BYTES - 1);
112535 byte_array.insert(byte_array.begin(), padding_size, 0);
112536 for (idx_t i = 0; i < byte_array.size(); i += DIGIT_BYTES) {
112537 digit_t hi = 0;
112538 for (idx_t j = 0; j < DIGIT_BYTES; j++) {
112539 hi |= UnsafeNumericCast<digit_t>(byte_array[i + j]) << (8 * (DIGIT_BYTES - j - 1));
112540 }
112541
112542 for (idx_t j = 0; j < digits.size(); j++) {
112543 twodigit_t tmp = UnsafeNumericCast<twodigit_t>(digits[j]) << DIGIT_BITS | hi;
112544 hi = static_cast<digit_t>(tmp / UnsafeNumericCast<twodigit_t>(DECIMAL_BASE));
112545 digits[j] = static_cast<digit_t>(tmp - UnsafeNumericCast<twodigit_t>(DECIMAL_BASE * hi));
112546 }
112547
112548 while (hi) {
112549 digits.push_back(hi % DECIMAL_BASE);
112550 hi /= DECIMAL_BASE;
112551 }
112552 }
112553
112554 if (digits.empty()) {
112555 digits.push_back(0);
112556 }
112557
112558 for (idx_t i = 0; i < digits.size() - 1; i++) {
112559 auto remain = digits[i];
112560 for (idx_t j = 0; j < DECIMAL_SHIFT; j++) {
112561 decimal_string += DigitToChar(static_cast<int>(remain % 10));
112562 remain /= 10;
112563 }
112564 }
112565
112566 auto remain = digits.back();
112567 do {
112568 decimal_string += DigitToChar(static_cast<int>(remain % 10));
112569 remain /= 10;
112570 } while (remain != 0);
112571
112572 if (is_negative) {
112573 decimal_string += '-';
112574 }
112575 // Reverse the string to get the correct decimal representation
112576 std::reverse(decimal_string.begin(), decimal_string.end());
112577 return decimal_string;
112578}
static DUCKDB_API void GetByteArray(vector< uint8_t > &byte_array, bool &is_negative, const string_t &blob)
Function to convert a string_t into a vector of bytes.
Definition duckdb.cpp:112489
static DUCKDB_API char DigitToChar(int digit)
Converts a Digit to a char.
Definition duckdb.cpp:112420
static DUCKDB_API constexpr digit_t DECIMAL_BASE
10 ** DECIMAL_SHIFT
Definition duckdb.cpp:46519
static DUCKDB_API constexpr uint8_t DIGIT_BITS
Bits of a digit_t.
Definition duckdb.cpp:46523
static DUCKDB_API constexpr uint8_t DECIMAL_SHIFT
Max(e such that 10**e fits in a digit_t).
Definition duckdb.cpp:46517
static DUCKDB_API constexpr uint8_t DIGIT_BYTES
Bytes of a digit_t.
Definition duckdb.cpp:46521
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VarcharToBignum()

string duckdb::Bignum::VarcharToBignum ( const string_t & value)
static

Function to convert Varchar to BIGNUM blob.

112580 {
112581 idx_t start_pos, end_pos;
112582 bool is_negative, is_zero;
112583 if (!VarcharFormatting(value, start_pos, end_pos, is_negative, is_zero)) {
112584 throw ConversionException("Could not convert string \'%s\' to Bignum", value.GetString());
112585 }
112586 if (is_zero) {
112587 // Return Value 0
112588 return InitializeBignumZero();
112589 }
112590 auto int_value_char = value.GetData();
112591 idx_t actual_size = end_pos - start_pos;
112592
112593 // we initalize result with space for our header
112594 string result(BIGNUM_HEADER_SIZE, '0');
112595 unsafe_vector<uint64_t> digits;
112596
112597 // The max number a uint64_t can represent is 18.446.744.073.709.551.615
112598 // That has 20 digits
112599 // In the worst case a remainder of a division will be 255, which is 3 digits
112600 // Since the max value is 184, we need to take one more digit out
112601 // Hence we end up with a max of 16 digits supported.
112602 constexpr uint8_t max_digits = 16;
112603 const idx_t number_of_digits = static_cast<idx_t>(std::ceil(static_cast<double>(actual_size) / max_digits));
112604
112605 // lets convert the string to a uint64_t vector
112606 idx_t cur_end = end_pos;
112607 for (idx_t i = 0; i < number_of_digits; i++) {
112608 idx_t cur_start = static_cast<int64_t>(start_pos) > static_cast<int64_t>(cur_end - max_digits)
112609 ? start_pos
112610 : cur_end - max_digits;
112611 std::string current_number(int_value_char + cur_start, cur_end - cur_start);
112612 digits.push_back(std::stoull(current_number));
112613 // move cur_end to more digits down the road
112614 cur_end = cur_end - max_digits;
112615 }
112616
112617 // Now that we have our uint64_t vector, lets start our division process to figure out the new number and remainder
112618 while (!digits.empty()) {
112619 idx_t digit_idx = digits.size() - 1;
112620 uint8_t remainder = 0;
112621 idx_t digits_size = digits.size();
112622 for (idx_t i = 0; i < digits_size; i++) {
112623 digits[digit_idx] += static_cast<uint64_t>(remainder * pow(10, max_digits));
112624 remainder = static_cast<uint8_t>(digits[digit_idx] % 256);
112625 digits[digit_idx] /= 256;
112626 if (digits[digit_idx] == 0 && digit_idx == digits.size() - 1) {
112627 // we can cap this
112628 digits.pop_back();
112629 }
112630 digit_idx--;
112631 }
112632 if (is_negative) {
112633 result.push_back(static_cast<char>(~remainder));
112634 } else {
112635 result.push_back(static_cast<char>(remainder));
112636 }
112637 }
112638 std::reverse(result.begin() + BIGNUM_HEADER_SIZE, result.end());
112639 // Set header after we know the size of the bignum
112640 SetHeader(&result[0], result.size() - BIGNUM_HEADER_SIZE, is_negative);
112641 return result;
112642}
static DUCKDB_API bool VarcharFormatting(const string_t &value, idx_t &start_pos, idx_t &end_pos, bool &is_negative, bool &is_zero)
Definition duckdb.cpp:112426
static DUCKDB_API bignum_t InitializeBignumZero(Vector &result)
Initializes and returns a blob with value 0, allocated in Vector& result.
Definition duckdb.cpp:112397
void pow(InputArray src, double power, OutputArray dst)
::int64_t int64_t
::uint64_t uint64_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BignumToDouble()

bool duckdb::Bignum::BignumToDouble ( const bignum_t & blob,
double & result,
bool & strict )
static

--------------------------------— Double Cast --------------------------------— //

112644 {
112645 result = 0;
112646
112647 if (blob.data.GetSize() < 4) {
112648 throw InvalidInputException("Invalid blob size.");
112649 }
112650 auto blob_ptr = blob.data.GetData();
112651
112652 // Determine if the number is negative
112653 bool is_negative = (blob_ptr[0] & 0x80) == 0;
112654 idx_t byte_pos = 0;
112655 for (idx_t i = blob.data.GetSize() - 1; i > 2; i--) {
112656 if (is_negative) {
112657 result += static_cast<uint8_t>(~blob_ptr[i]) * pow(256, static_cast<double>(byte_pos));
112658 } else {
112659 result += static_cast<uint8_t>(blob_ptr[i]) * pow(256, static_cast<double>(byte_pos));
112660 }
112661 byte_pos++;
112662 }
112663
112664 if (is_negative) {
112665 result *= -1;
112666 }
112667 if (!std::isfinite(result)) {
112668 // We throw an error
112669 throw ConversionException("Could not convert bignum '%s' to Double", BignumToVarchar(blob));
112670 }
112671 return true;
112672}
static DUCKDB_API string BignumToVarchar(const bignum_t &blob)
Function to convert BIGNUM blob to a VARCHAR.
Definition duckdb.cpp:112526
Here is the call graph for this function:

◆ BignumToInt()

template<class T>
bool duckdb::Bignum::BignumToInt ( const bignum_t & blob,
T & result,
bool & strict )
inlinestatic
46559 {
46560 auto data_byte_size = blob.data.GetSize() - BIGNUM_HEADER_SIZE;
46561 auto data = blob.data.GetData();
46562 bool is_negative = (data[0] & 0x80) == 0;
46563
46564 uhugeint_t abs_value = 0;
46565 for (idx_t i = 0; i < data_byte_size; ++i) {
46566 uint8_t byte = static_cast<uint8_t>(data[Bignum::BIGNUM_HEADER_SIZE + i]);
46567 if (is_negative) {
46568 byte = ~byte;
46569 }
46570 abs_value = (abs_value << 8) | byte;
46571 }
46572
46573 if (is_negative) {
46574 if (abs_value > static_cast<uhugeint_t>(std::numeric_limits<T>::max()) + 1) {
46575 throw OutOfRangeException("Negative bignum too small for type");
46576 }
46577 result = static_cast<T>(-static_cast<hugeint_t>(abs_value));
46578 } else {
46579 if (abs_value > static_cast<uhugeint_t>(std::numeric_limits<T>::max())) {
46580 throw OutOfRangeException("Positive bignum too large for type");
46581 }
46582 result = static_cast<T>(abs_value);
46583 }
46584 return true;
46585 }

Member Data Documentation

◆ MAX_DATA_SIZE

DUCKDB_API constexpr uint32_t duckdb::Bignum::MAX_DATA_SIZE = 8388607
staticconstexpr

This is the maximum number of bytes a BIGNUM can have on it's data size i.e., 2^(8*3-1) - 1.


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