30#ifndef LSST_SPHGEOM_BIGINTEGER_H_
31#define LSST_SPHGEOM_BIGINTEGER_H_
64 _checkCapacity(b._size);
67 std::memcpy(_digits, b._digits,
sizeof(std::uint32_t) * b._size);
77 unsigned getSize()
const {
return _size; }
84 std::uint32_t
const *
getDigits()
const {
return _digits; }
92 setTo(
static_cast<std::uint64_t
>(-x));
95 setTo(
static_cast<std::uint64_t
>(x));
102 _digits[0] =
static_cast<std::uint32_t
>(x);
103 _digits[1] =
static_cast<std::uint32_t
>(x >> 32);
104 _size = (_digits[1] == 0) ? (_digits[0] != 0) : 2;
105 _sign = (_size != 0);
125 void _checkCapacity(
unsigned n)
const {
127 throw std::runtime_error(
"BigInteger capacity is too small");
131 std::uint32_t * _digits;
Definition BigInteger.h:51
BigInteger & subtract(BigInteger const &b)
subtract subtracts b from this integer.
Definition BigInteger.cc:208
void setTo(std::int64_t x)
setTo sets this integer to the given signed 64 bit integer value.
Definition BigInteger.h:90
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:87
void setTo(std::uint64_t x)
setTo sets this integer to the given unsigned 64 bit integer value.
Definition BigInteger.h:100
int getSign() const
Definition BigInteger.h:74
void negate()
negate multiplies this integer by -1.
Definition BigInteger.h:109
BigInteger & add(BigInteger const &b)
add adds b to this integer.
Definition BigInteger.cc:163
unsigned getCapacity() const
Definition BigInteger.h:81
std::uint32_t const * getDigits() const
getDigits returns the underlying digit array.
Definition BigInteger.h:84
BigInteger(std::uint32_t *digits, unsigned capacity)
Definition BigInteger.h:55
unsigned getSize() const
getSize returns the number of digits in the value of this integer.
Definition BigInteger.h:77