BigNum.cxx File Reference

#include <assert.h>
#include <string>
#include <string.h>
#include <libsherpa/BigNum.hxx>
#include <libsherpa/UExcept.hxx>

Go to the source code of this file.

Namespaces

namespace  sherpa

Data Structures

struct  sherpa::nvec

Functions

static void * rmemset (void *s, int c, size_t n)
 memset, but initializing from top to bottom.
static uint32_t max (uint32_t a, uint32_t b)
static uint32_t min (uint32_t a, uint32_t b)
static int sherpa::vu_cmp (const nvec n1, const nvec n2)
 compare two digit vectors for relative magnitude. Return -1, 0, 1 according to whether v1 is less than, equal to, or greater than v2.
static void sherpa::vu_rshift_digits (const nvec n1, size_t nShift, nvec n2)
 n2 = n1 / (radix^nShift)
static void sherpa::vu_lshift_digits (const nvec n1, size_t nShift, nvec n2)
 n2 = n1 * (radix^nShift)
static void sherpa::vu_rshift_bits (const nvec n1, size_t nShift, nvec n2)
 n2 = n1 >> nShift
static void sherpa::vu_lshift_bits (const nvec n1, size_t nShift, nvec n2)
 n2 = n1 << nShift
static unsigned sherpa::vu_get_bit (const nvec n1, size_t bit)
static void sherpa::vu_set_bit (nvec n1, size_t bit)
static void sherpa::vu_clear_bit (nvec n1, size_t bit)
static void sherpa::vu_copy (const nvec n1, nvec n2)
static void sherpa::vu_sub (const nvec n1, const nvec n2, nvec n3)
 Subtract: n3 = n1 - n2.
static void sherpa::vu_add (const nvec n1, const nvec n2, nvec n3)
 Add: n3 = n1 + n2.
static void sherpa::vu_mul (const nvec n1, const nvec n2, nvec n3)
 Multiply: n3 = n1 * n2.
static void sherpa::vu_divqr (const nvec dividend, const nvec divisor, nvec quotient, nvec remainder)
 Divide q = n1 / n2, r = (n1 - (n2 * q)).

Variables

const uint64_t UINT32_T_MAX = 4294967295ull
static uint32_t sherpa::u_zero = 0
static const nvec sherpa::nv_zero (1,&u_zero)
static uint32_t sherpa::u_one = 1
static const nvec sherpa::nv_one (1,&u_one)


Function Documentation

static uint32_t max ( uint32_t  a,
uint32_t  b 
) [inline, static]

Definition at line 65 of file BigNum.cxx.

Referenced by calc_unin_size(), sherpa::BigNum::operator+(), sherpa::BigNum::operator-(), and sherpa::vu_cmp().

static uint32_t min ( uint32_t  a,
uint32_t  b 
) [inline, static]

Definition at line 70 of file BigNum.cxx.

Referenced by sherpa::vu_lshift_bits(), sherpa::vu_lshift_digits(), and sherpa::vu_rshift_digits().

static void* rmemset ( void *  s,
int  c,
size_t  n 
) [static]

memset, but initializing from top to bottom.

In large heap-allocated vectors a segv can occur if a reference occurs too far below bottom of stack. The easiest way to prevent this is to touch the bytes in the proper order.

Definition at line 56 of file BigNum.cxx.

Referenced by sherpa::vu_divqr(), and sherpa::vu_mul().


Variable Documentation

const uint64_t UINT32_T_MAX = 4294967295ull

Definition at line 48 of file BigNum.cxx.

Referenced by sherpa::BigNum::BigNum(), and sherpa::vu_sub().


Generated on Sat Feb 4 23:59:29 2012 for BitC Compiler by  doxygen 1.4.7