/// Sets the least significant part of a bignum to the input value, and zeroes
/// out higher parts.
- static void tcSet(integerPart *, integerPart, unsigned int);
+ static void tcSet(integerPart *, integerPart, unsigned);
/// Assign one bignum to another.
- static void tcAssign(integerPart *, const integerPart *, unsigned int);
+ static void tcAssign(integerPart *, const integerPart *, unsigned);
/// Returns true if a bignum is zero, false otherwise.
- static bool tcIsZero(const integerPart *, unsigned int);
+ static bool tcIsZero(const integerPart *, unsigned);
/// Extract the given bit of a bignum; returns 0 or 1. Zero-based.
- static int tcExtractBit(const integerPart *, unsigned int bit);
+ static int tcExtractBit(const integerPart *, unsigned bit);
/// Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to
/// DST, of dstCOUNT parts, such that the bit srcLSB becomes the least
/// significant bit of DST. All high bits above srcBITS in DST are
/// zero-filled.
- static void tcExtract(integerPart *, unsigned int dstCount,
- const integerPart *, unsigned int srcBits,
- unsigned int srcLSB);
+ static void tcExtract(integerPart *, unsigned dstCount,
+ const integerPart *, unsigned srcBits,
+ unsigned srcLSB);
/// Set the given bit of a bignum. Zero-based.
- static void tcSetBit(integerPart *, unsigned int bit);
+ static void tcSetBit(integerPart *, unsigned bit);
/// Clear the given bit of a bignum. Zero-based.
- static void tcClearBit(integerPart *, unsigned int bit);
+ static void tcClearBit(integerPart *, unsigned bit);
/// Returns the bit number of the least or most significant set bit of a
/// number. If the input number has no bits set -1U is returned.
- static unsigned int tcLSB(const integerPart *, unsigned int);
- static unsigned int tcMSB(const integerPart *parts, unsigned int n);
+ static unsigned tcLSB(const integerPart *, unsigned n);
+ static unsigned tcMSB(const integerPart *parts, unsigned n);
/// Negate a bignum in-place.
- static void tcNegate(integerPart *, unsigned int);
+ static void tcNegate(integerPart *, unsigned);
/// DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
static integerPart tcAdd(integerPart *, const integerPart *,
/// otherwise overflow occurred and return one.
static int tcMultiplyPart(integerPart *dst, const integerPart *src,
integerPart multiplier, integerPart carry,
- unsigned int srcParts, unsigned int dstParts,
+ unsigned srcParts, unsigned dstParts,
bool add);
/// DST = LHS * RHS, where DST has the same width as the operands and is
/// DST = LHS * RHS, where DST has width the sum of the widths of the
/// operands. No overflow occurs. DST must be disjoint from both
/// operands. Returns the number of parts required to hold the result.
- static unsigned int tcFullMultiply(integerPart *, const integerPart *,
- const integerPart *, unsigned, unsigned);
+ static unsigned tcFullMultiply(integerPart *, const integerPart *,
+ const integerPart *, unsigned, unsigned);
/// If RHS is zero LHS and REMAINDER are left unchanged, return one.
/// Otherwise set LHS to LHS / RHS with the fractional part discarded, set
/// REMAINDER and SCRATCH must be distinct.
static int tcDivide(integerPart *lhs, const integerPart *rhs,
integerPart *remainder, integerPart *scratch,
- unsigned int parts);
+ unsigned parts);
/// Shift a bignum left COUNT bits. Shifted in bits are zero. There are no
/// restrictions on COUNT.
- static void tcShiftLeft(integerPart *, unsigned int parts,
- unsigned int count);
+ static void tcShiftLeft(integerPart *, unsigned parts, unsigned count);
/// Shift a bignum right COUNT bits. Shifted in bits are zero. There are no
/// restrictions on COUNT.
- static void tcShiftRight(integerPart *, unsigned int parts,
- unsigned int count);
+ static void tcShiftRight(integerPart *, unsigned parts, unsigned count);
/// The obvious AND, OR and XOR and complement operations.
- static void tcAnd(integerPart *, const integerPart *, unsigned int);
- static void tcOr(integerPart *, const integerPart *, unsigned int);
- static void tcXor(integerPart *, const integerPart *, unsigned int);
- static void tcComplement(integerPart *, unsigned int);
+ static void tcAnd(integerPart *, const integerPart *, unsigned);
+ static void tcOr(integerPart *, const integerPart *, unsigned);
+ static void tcXor(integerPart *, const integerPart *, unsigned);
+ static void tcComplement(integerPart *, unsigned);
/// Comparison (unsigned) of two bignums.
- static int tcCompare(const integerPart *, const integerPart *, unsigned int);
+ static int tcCompare(const integerPart *, const integerPart *, unsigned);
/// Increment a bignum in-place. Return the carry flag.
- static integerPart tcIncrement(integerPart *, unsigned int);
+ static integerPart tcIncrement(integerPart *, unsigned);
/// Decrement a bignum in-place. Return the borrow flag.
- static integerPart tcDecrement(integerPart *, unsigned int);
+ static integerPart tcDecrement(integerPart *, unsigned);
/// Set the least significant BITS and clear the rest.
- static void tcSetLeastSignificantBits(integerPart *, unsigned int,
- unsigned int bits);
+ static void tcSetLeastSignificantBits(integerPart *, unsigned, unsigned bits);
/// \brief debug method
void dump() const;
/* Returns the integer part with the least significant BITS set.
BITS cannot be zero. */
static inline integerPart
- lowBitMask(unsigned int bits)
+ lowBitMask(unsigned bits)
{
assert(bits != 0 && bits <= integerPartWidth);
/* Returns the bit number of the most significant set bit of a part.
If the input number has no bits set -1U is returned. */
- static unsigned int
+ static unsigned
partMSB(integerPart value)
{
return findLastSet(value, ZB_Max);
/* Returns the bit number of the least significant set bit of a
part. If the input number has no bits set -1U is returned. */
- static unsigned int
+ static unsigned
partLSB(integerPart value)
{
return findFirstSet(value, ZB_Max);
/* Sets the least significant part of a bignum to the input value, and
zeroes out higher parts. */
void
-APInt::tcSet(integerPart *dst, integerPart part, unsigned int parts)
+APInt::tcSet(integerPart *dst, integerPart part, unsigned parts)
{
unsigned int i;
/* Assign one bignum to another. */
void
-APInt::tcAssign(integerPart *dst, const integerPart *src, unsigned int parts)
+APInt::tcAssign(integerPart *dst, const integerPart *src, unsigned parts)
{
unsigned int i;
/* Returns true if a bignum is zero, false otherwise. */
bool
-APInt::tcIsZero(const integerPart *src, unsigned int parts)
+APInt::tcIsZero(const integerPart *src, unsigned parts)
{
unsigned int i;
/* Extract the given bit of a bignum; returns 0 or 1. */
int
-APInt::tcExtractBit(const integerPart *parts, unsigned int bit)
+APInt::tcExtractBit(const integerPart *parts, unsigned bit)
{
return (parts[bit / integerPartWidth] &
((integerPart) 1 << bit % integerPartWidth)) != 0;
/* Set the given bit of a bignum. */
void
-APInt::tcSetBit(integerPart *parts, unsigned int bit)
+APInt::tcSetBit(integerPart *parts, unsigned bit)
{
parts[bit / integerPartWidth] |= (integerPart) 1 << (bit % integerPartWidth);
}
/* Clears the given bit of a bignum. */
void
-APInt::tcClearBit(integerPart *parts, unsigned int bit)
+APInt::tcClearBit(integerPart *parts, unsigned bit)
{
parts[bit / integerPartWidth] &=
~((integerPart) 1 << (bit % integerPartWidth));
/* Returns the bit number of the least significant set bit of a
number. If the input number has no bits set -1U is returned. */
-unsigned int
-APInt::tcLSB(const integerPart *parts, unsigned int n)
+unsigned
+APInt::tcLSB(const integerPart *parts, unsigned n)
{
unsigned int i, lsb;
/* Returns the bit number of the most significant set bit of a number.
If the input number has no bits set -1U is returned. */
-unsigned int
-APInt::tcMSB(const integerPart *parts, unsigned int n)
+unsigned
+APInt::tcMSB(const integerPart *parts, unsigned n)
{
unsigned int msb;
the least significant bit of DST. All high bits above srcBITS in
DST are zero-filled. */
void
-APInt::tcExtract(integerPart *dst, unsigned int dstCount,const integerPart *src,
- unsigned int srcBits, unsigned int srcLSB)
+APInt::tcExtract(integerPart *dst, unsigned dstCount,const integerPart *src,
+ unsigned srcBits, unsigned srcLSB)
{
unsigned int firstSrcPart, dstParts, shift, n;
/* DST += RHS + C where C is zero or one. Returns the carry flag. */
integerPart
APInt::tcAdd(integerPart *dst, const integerPart *rhs,
- integerPart c, unsigned int parts)
+ integerPart c, unsigned parts)
{
unsigned int i;
/* DST -= RHS + C where C is zero or one. Returns the carry flag. */
integerPart
APInt::tcSubtract(integerPart *dst, const integerPart *rhs,
- integerPart c, unsigned int parts)
+ integerPart c, unsigned parts)
{
unsigned int i;
/* Negate a bignum in-place. */
void
-APInt::tcNegate(integerPart *dst, unsigned int parts)
+APInt::tcNegate(integerPart *dst, unsigned parts)
{
tcComplement(dst, parts);
tcIncrement(dst, parts);
int
APInt::tcMultiplyPart(integerPart *dst, const integerPart *src,
integerPart multiplier, integerPart carry,
- unsigned int srcParts, unsigned int dstParts,
+ unsigned srcParts, unsigned dstParts,
bool add)
{
unsigned int i, n;
from both operands. */
int
APInt::tcMultiply(integerPart *dst, const integerPart *lhs,
- const integerPart *rhs, unsigned int parts)
+ const integerPart *rhs, unsigned parts)
{
unsigned int i;
int overflow;
operands. No overflow occurs. DST must be disjoint from both
operands. Returns the number of parts required to hold the
result. */
-unsigned int
+unsigned
APInt::tcFullMultiply(integerPart *dst, const integerPart *lhs,
- const integerPart *rhs, unsigned int lhsParts,
- unsigned int rhsParts)
+ const integerPart *rhs, unsigned lhsParts,
+ unsigned rhsParts)
{
/* Put the narrower number on the LHS for less loops below. */
if (lhsParts > rhsParts) {
int
APInt::tcDivide(integerPart *lhs, const integerPart *rhs,
integerPart *remainder, integerPart *srhs,
- unsigned int parts)
+ unsigned parts)
{
unsigned int n, shiftCount;
integerPart mask;
/* Shift a bignum left COUNT bits in-place. Shifted in bits are zero.
There are no restrictions on COUNT. */
void
-APInt::tcShiftLeft(integerPart *dst, unsigned int parts, unsigned int count)
+APInt::tcShiftLeft(integerPart *dst, unsigned parts, unsigned count)
{
if (count) {
unsigned int jump, shift;
/* Shift a bignum right COUNT bits in-place. Shifted in bits are
zero. There are no restrictions on COUNT. */
void
-APInt::tcShiftRight(integerPart *dst, unsigned int parts, unsigned int count)
+APInt::tcShiftRight(integerPart *dst, unsigned parts, unsigned count)
{
if (count) {
unsigned int i, jump, shift;
/* Bitwise and of two bignums. */
void
-APInt::tcAnd(integerPart *dst, const integerPart *rhs, unsigned int parts)
+APInt::tcAnd(integerPart *dst, const integerPart *rhs, unsigned parts)
{
unsigned int i;
/* Bitwise inclusive or of two bignums. */
void
-APInt::tcOr(integerPart *dst, const integerPart *rhs, unsigned int parts)
+APInt::tcOr(integerPart *dst, const integerPart *rhs, unsigned parts)
{
unsigned int i;
/* Bitwise exclusive or of two bignums. */
void
-APInt::tcXor(integerPart *dst, const integerPart *rhs, unsigned int parts)
+APInt::tcXor(integerPart *dst, const integerPart *rhs, unsigned parts)
{
unsigned int i;
/* Complement a bignum in-place. */
void
-APInt::tcComplement(integerPart *dst, unsigned int parts)
+APInt::tcComplement(integerPart *dst, unsigned parts)
{
unsigned int i;
/* Comparison (unsigned) of two bignums. */
int
APInt::tcCompare(const integerPart *lhs, const integerPart *rhs,
- unsigned int parts)
+ unsigned parts)
{
while (parts) {
parts--;
/* Increment a bignum in-place, return the carry flag. */
integerPart
-APInt::tcIncrement(integerPart *dst, unsigned int parts)
+APInt::tcIncrement(integerPart *dst, unsigned parts)
{
unsigned int i;
/* Decrement a bignum in-place, return the borrow flag. */
integerPart
-APInt::tcDecrement(integerPart *dst, unsigned int parts) {
- for (unsigned int i = 0; i < parts; i++) {
+APInt::tcDecrement(integerPart *dst, unsigned parts) {
+ for (unsigned i = 0; i < parts; i++) {
// If the current word is non-zero, then the decrement has no effect on the
// higher-order words of the integer and no borrow can occur. Exit early.
if (dst[i]--)
/* Set the least significant BITS bits of a bignum, clear the
rest. */
void
-APInt::tcSetLeastSignificantBits(integerPart *dst, unsigned int parts,
- unsigned int bits)
+APInt::tcSetLeastSignificantBits(integerPart *dst, unsigned parts,
+ unsigned bits)
{
unsigned int i;