C++ SDK Documentation  9.0
Basics::BigInt Struct Reference
Collaboration diagram for Basics::BigInt:
Collaboration graph

Classes

union  long_double_parts
 

Static Public Member Functions

static uint64 accumulateNN (void *outBuf, const void *buf1, int nWords)
 Add number on to a temporary No null handling Returns carry.
 
static uint64 addNN (void *outBuf, const void *buf1, const void *buf2, int nWords)
 Add together 2 numbers w/ same number of digits No null handling Returns carry.
 
static void castNumeric (uint64 *wordso, int nwdso, int32 typmodo, uint64 *wordsi, int nwdsi, int32 typmodi)
 
static bool checkOverflowNN (const void *po, int nwdso, int32 typmodo)
 
static bool checkOverflowNN (const void *po, int nwo, int nwdso, int32 typmodo)
 
static int compareNN (const void *buf1, const void *buf2, int nWords)
 Compare integers, return -1, 0, 1.
 
static long double convertPosToFloatNN (const void *bbuf, int bwords)
 Convert Numeric to a float helper function Input should not be negative / null.
 
static void copy (void *buf, const void *src, int nWords)
 cpoy nWords from src to buf
 
static uint64 divUnsignedN1 (void *qbuf, int qw, int round, const void *ubuf, int uw, uint64 v)
 
static void divUnsignedNN (void *qbuf, int qw, int round, uint64 *rbuf, int rw, const void *ubuf, int uw, const void *vbuf, int vw)
 
static void fromIntNN (void *buf, int nWords, int64 val)
 Load from 64-bit signed int (does not handle NULL inside)
 
static void incrementNN (void *buf, int nWords)
 Increment by 1.
 
static void invertSign (void *buf, int nWords)
 Invert the sign of a number, performed in place, using the invert and +1 method, turns out NULLs are OK in this sense.
 
static bool isEqualNN (const void *buf1, const void *buf2, int nWords)
 Check integers for equality. More...
 
static bool isNeg (const void *buf, int nWords)
 Check if integer is less than zero.
 
static bool isNull (const void *buf, int nWords)
 Check an integer for NULL.
 
static bool isZero (const void *buf, int nWords)
 Check an integer for 0. More...
 
static void mulUnsignedN1 (void *obuf, const void *ubuf, int uw, uint64 v)
 Multiply, unsigned only. uw words by 1 word -> uw+1 words Output array must be uw+1 words long; may not overlap inputs.
 
static void mulUnsignedNN (void *obuf, const void *buf1, int nw1, const void *buf2, int nw2)
 Multiply, unsigned only. Output array must be nw1+nw2 long; may not overlap inputs PERF NOTE: Operates like a school boy, could do Karatsuba (or better)
 
static void numericDivide (const uint64 *pa, int nwdsa, int32 typmoda, const uint64 *pb, int nwdsb, int32 typmodb, uint64 *outNum, int nwdso, int32 typmodo)
 Divide Numerics Handles negative / null input.
 
static void numericMultiply (const uint64 *pa, int nwdsa, const uint64 *pb, int nwdsb, uint64 *outNum, int nwdso)
 Multiply Numerics , result in outNum Handles negative / null input.
 
static void NumericRescaleDown (uint64 *wordso, int nwdso, int32 typmodo, uint64 *wordsi, int nwdsi, int32 typmodi)
 
static void NumericRescaleSameScaleSmallerPrec (uint64 *wordso, int nwdso, int32 typmodo, uint64 *wordsi, int nwdsi, int32 typmodi)
 
static void NumericRescaleUp (uint64 *wordso, int nwdso, int32 typmodo, uint64 *wordsi, int nwdsi, int32 typmodi)
 
static ifloat numericToFloat (const void *buf, int nwds, ifloat tenthtoscale)
 Convert Numeric to a float Handles negative / null input. More...
 
static bool rescaleNumeric (void *out, int ow, int pout, int sout, void *in, int iw, int pin, int sin)
 Rescale a given numeric to a specific prec/scale/nwds The input should have minimal precision to avoid unnecessary overflow; for example, "0" should have precision 0 (as generated by charToNumeric). Accepts signed numerics. Will set its "in" argument to abs(in).
 
static bool setFromFloat (void *bbuf, int bwords, int typmod, long double value, bool round)
 Convert floating point multiplied by 10^scale to an integer This truncates if round is false; otherwise the numeric result is rounded. More...
 
static void setNull (void *buf, int nWords)
 Set an integer to NULL.
 
static void setNumericBoundsFromType (uint64 *numUpperBound, uint64 *numLowerBound, int nwdso, int32 typmod)
 
static void setZero (void *buf, int nWords)
 Set an integer to 0.
 
static void shiftLeftNN (void *buf, unsigned nw, unsigned bitsToShift)
 Shift a BigInt to the left (<<) by the given number of bits. The given BigInt must be positive and non-null.
 
static void shiftRightNN (void *buf, unsigned nw, unsigned bitsToShift)
 Shift a BigInt to the right (>>) by the given number of bits. The given BigInt must be positive and non-null.
 
static void subNN (void *outBuf, const void *buf1, const void *buf2, int nWords)
 Subtract 2 numbers w/ same number of digits No null handling.
 
static bool toIntNN (int64 &out, const void *buf, int nWords)
 Convert to int (return false if there was an overflow)
 
static int ucompareNN (const void *buf1, const void *buf2, int nWords)
 
static int usedWordsUnsigned (const void *buf, int nWords)
 Calculate number of words that are actually used to represent the value (amount left after stripping leading 0's)
 

Detailed Description

Holds integer utilities A few are inlined for performance reasons. Most are in vertica.cpp.

Member Function Documentation

static bool Basics::BigInt::isEqualNN ( const void *  buf1,
const void *  buf2,
int  nWords 
)
static

Check integers for equality.

Note
Optimized for small nWords; scan from end and break out of loop

Referenced by Vertica::VNumeric::equal().

static bool Basics::BigInt::isZero ( const void *  buf,
int  nWords 
)
static

Check an integer for 0.

Note
Optimized for small nWords; scan from end and break out of loop

Referenced by Vertica::VNumeric::isZero().

static ifloat Basics::BigInt::numericToFloat ( const void *  buf,
int  nwds,
ifloat  tenthtoscale 
)
static

Convert Numeric to a float Handles negative / null input.

Parameters
tenthtoscale10^-scale of the Numeric

Referenced by Vertica::VNumeric::toFloat().

bool Basics::BigInt::setFromFloat ( void *  bbuf,
int  bwords,
int  typmod,
long double  value,
bool  round 
)
static

Convert floating point multiplied by 10^scale to an integer This truncates if round is false; otherwise the numeric result is rounded.

Returns
false if high bits were lost, true if reasonable fidelity was achieved

Referenced by Vertica::VNumeric::copy().

static int Basics::BigInt::ucompareNN ( const void *  buf1,
const void *  buf2,
int  nWords 
)
inlinestatic

Compare integers, return -1, 0, 1

Referenced by Vertica::VNumeric::compareUnsigned().