X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Farbint.h;h=ae0b23e06fc798e678dfa57821bb79cbb8f17a23;hp=06008e072fcb3e5df96e303ca17be7b08f3c26a0;hb=b02dcbab39b8c28b9baa41436842ca9fe4ae7ffd;hpb=924cb525f587c58440c43bcae6ccfd9b2e41c99c diff --git a/src/arbint.h b/src/arbint.h index 06008e0..ae0b23e 100644 --- a/src/arbint.h +++ b/src/arbint.h @@ -68,6 +68,13 @@ namespace IPDF return a; } + inline Arbint operator-() const + { + Arbint a(*this); + a.m_sign = !a.m_sign; + return a; + } + inline Arbint operator*(const Arbint & mul) const { Arbint a(*this); @@ -99,6 +106,7 @@ namespace IPDF bool operator==(const Arbint & equ) const; bool operator<(const Arbint & less) const; + inline bool operator!=(const Arbint & equ) const { @@ -130,11 +138,11 @@ namespace IPDF return result; } bool IsZero() const; - - inline operator double() const + + inline operator double() const { double acc = 0; - for(int i = m_digits.size()-1; i >= 0; --i) + for (int i = m_digits.size()-1; i >= 0; --i) { acc += (double)m_digits[i]; acc *= (double)UINT64_MAX + 1.0; @@ -153,6 +161,8 @@ namespace IPDF Arbint & AddBasic(const Arbint & add); Arbint & SubBasic(const Arbint & sub); + void GrowDigit(digit_t new_msd); // add a new most significant digit + bool GetBit(unsigned i) const; void BitClear(unsigned i); void BitSet(unsigned i);