30#ifndef LSST_SPHGEOM_BIGINTEGER_H_
31#define LSST_SPHGEOM_BIGINTEGER_H_
65 _checkCapacity(b._size);
68 std::memcpy(_digits, b._digits,
sizeof(uint32_t) * b._size);
78 unsigned getSize()
const {
return _size; }
85 uint32_t
const *
getDigits()
const {
return _digits; }
93 setTo(
static_cast<uint64_t
>(-x));
96 setTo(
static_cast<uint64_t
>(x));
103 _digits[0] =
static_cast<uint32_t
>(x);
104 _digits[1] =
static_cast<uint32_t
>(x >> 32);
105 _size = (_digits[1] == 0) ? (_digits[0] != 0) : 2;
106 _sign = (_size != 0);
126 void _checkCapacity(
unsigned n)
const {
128 throw std::runtime_error(
"BigInteger capacity is too small");
Definition BigInteger.h:52
BigInteger & subtract(BigInteger const &b)
subtract subtracts b from this integer.
Definition BigInteger.cc:208
BigInteger & multiply(BigInteger const &b)
multiply multiplies this integer by b.
Definition BigInteger.cc:256
BigInteger & multiplyPow2(unsigned n)
multiplyPow2 multiplies this integer by 2ⁿ.
Definition BigInteger.cc:221
void setToZero()
setToZero sets this integer to zero.
Definition BigInteger.h:88
BigInteger(uint32_t *digits, unsigned capacity)
Definition BigInteger.h:56
int getSign() const
Definition BigInteger.h:75
void negate()
negate multiplies this integer by -1.
Definition BigInteger.h:110
BigInteger & add(BigInteger const &b)
add adds b to this integer.
Definition BigInteger.cc:163
unsigned getCapacity() const
Definition BigInteger.h:82
void setTo(uint64_t x)
setTo sets this integer to the given unsigned 64 bit integer value.
Definition BigInteger.h:101
unsigned getSize() const
getSize returns the number of digits in the value of this integer.
Definition BigInteger.h:78
void setTo(int64_t x)
setTo sets this integer to the given signed 64 bit integer value.
Definition BigInteger.h:91
uint32_t const * getDigits() const
getDigits returns the underlying digit array.
Definition BigInteger.h:85