Basics::BigInt Struct Reference

Collaboration diagram for Basics::BigInt:

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 bool castNumeric (uint64 *wordso, int nwdso, Typemod typmodo, uint64 *wordsi, int nwdsi, Typemod typmodi, bool throw_error=true)
static bool castNumeric (uint64 *wordso, int nwdso, int32 numericattro, uint64 *wordsi, int nwdsi, int32 numericattri, bool throw_error=true)
static bool checkOverflowNN (const void *po, int nwdso, Typemod typmodo)
static bool checkOverflowNN (const void *po, int nwo, int nwdso, Typemod typmodo)
static bool checkOverflowNN (const void *po, int nwdso, int32 numericattro)
static bool checkOverflowNN (const void *po, int nwo, int nwdso, int32 numericattro)
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.
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.
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, Typemod typmoda, const uint64 *pb, int nwdsb, Typemod typmodb, uint64 *outNum, int nwdso, Typemod typmodo)
Divide Numerics Handles negative / null input.
static void numericDivide (const uint64 *pa, int nwdsa, int32 numericattra, const uint64 *pb, int nwdsb, int32 numericattrb, uint64 *outNum, int nwdso, int32 numericattro)
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 bool NumericRescaleDown (uint64 *wordso, int nwdso, Typemod typmodo, uint64 *wordsi, int nwdsi, Typemod typmodi, bool throw_errors=true)
static bool NumericRescaleDown (uint64 *wordso, int nwdso, int32 numericattro, uint64 *wordsi, int nwdsi, int32 numericattri, bool throw_error=true)
static bool NumericRescaleSameScaleSmallerPrec (uint64 *wordso, int nwdso, Typemod typmodo, uint64 *wordsi, int nwdsi, Typemod typmodi, bool throw_errors=true)
static bool NumericRescaleSameScaleSmallerPrec (uint64 *wordso, int nwdso, int32 numericattro, uint64 *wordsi, int nwdsi, int32 numericattri, bool throw_error=true)
static bool NumericRescaleUp (uint64 *wordso, int nwdso, Typemod typmodo, uint64 *wordsi, int nwdsi, Typemod typmodi, bool throw_errors=true)
static bool NumericRescaleUp (uint64 *wordso, int nwdso, int32 numericattro, uint64 *wordsi, int nwdsi, int32 numericattri, bool throw_error=true)
static ifloat numericToFloat (const void *buf, int nwds, ifloat tenthtoscale)
Convert Numeric to a float Handles negative / null input.
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, Typemod 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.
static bool setFromFloat (void *bbuf, int bwords, int32 numericattr, long double value, bool round)
static void setNull (void *buf, int nWords)
Set an integer to NULL.
static void setNumericBoundsFromType (uint64 *numUpperBound, uint64 *numLowerBound, int nwdso, Typemod typmod)
static void setNumericBoundsFromType (uint64 *numUpperBound, uint64 *numLowerBound, int nwdso, int32 numericattr)
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 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

isEqualNN()

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().

isZero()

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().

numericToFloat()

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

static

Convert Numeric to a float Handles negative / null input.

Parameters

  • tenthtoscale: 10^-scale of the Numeric

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

setFromFloat()

bool Basics::BigInt::setFromFloat(void * bbuf, int bwords, Typemod 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().

ucompareNN()

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().