23#ifndef LSST_SPHGEOM_BIGINTEGER_H_
24#define LSST_SPHGEOM_BIGINTEGER_H_
58 _checkCapacity(b._size);
61 std::memcpy(_digits, b._digits,
sizeof(uint32_t) * b._size);
71 unsigned getSize()
const {
return _size; }
78 uint32_t
const *
getDigits()
const {
return _digits; }
86 setTo(
static_cast<uint64_t
>(-x));
89 setTo(
static_cast<uint64_t
>(x));
96 _digits[0] =
static_cast<uint32_t
>(x);
97 _digits[1] =
static_cast<uint32_t
>(x >> 32);
98 _size = (_digits[1] == 0) ? (_digits[0] != 0) : 2;
119 void _checkCapacity(
unsigned n)
const {
121 throw std::runtime_error(
"BigInteger capacity is too small");
Definition: BigInteger.h:45
BigInteger & subtract(BigInteger const &b)
subtract subtracts b from this integer.
Definition: BigInteger.cc:201
BigInteger & multiply(BigInteger const &b)
multiply multiplies this integer by b.
Definition: BigInteger.cc:249
BigInteger & multiplyPow2(unsigned n)
multiplyPow2 multiplies this integer by 2ⁿ.
Definition: BigInteger.cc:214
void setToZero()
setToZero sets this integer to zero.
Definition: BigInteger.h:81
BigInteger(uint32_t *digits, unsigned capacity)
Definition: BigInteger.h:49
int getSign() const
Definition: BigInteger.h:68
void negate()
negate multiplies this integer by -1.
Definition: BigInteger.h:103
BigInteger & add(BigInteger const &b)
add adds b to this integer.
Definition: BigInteger.cc:156
unsigned getCapacity() const
Definition: BigInteger.h:75
void setTo(uint64_t x)
setTo sets this integer to the given unsigned 64 bit integer value.
Definition: BigInteger.h:94
unsigned getSize() const
getSize returns the number of digits in the value of this integer.
Definition: BigInteger.h:71
void setTo(int64_t x)
setTo sets this integer to the given signed 64 bit integer value.
Definition: BigInteger.h:84
uint32_t const * getDigits() const
getDigits returns the underlying digit array.
Definition: BigInteger.h:78