virtual ~Arbint() {}
Arbint(const Arbint & cpy);
- int64_t AsDigit() const
+ int64_t AsDigit() const
{
- int64_t digit = (m_digits.size() == 1) ? m_digits[0] : 0x7FFFFFFFFFFFFFFF;
+ int64_t digit = (m_digits.size() == 1) ? m_digits[0] : 0xBADF00D;
return (m_sign) ? -digit : digit;
}
a -= add;
return a;
}
+
+ inline Arbint operator-()
+ {
+ Arbint a(*this);
+ a.m_sign = !a.m_sign;
+ return a;
+ }
+
+ inline Arbint operator-() const
+ {
+ Arbint a(*this);
+ a.m_sign = !a.m_sign;
+ return a;
+ }
inline Arbint operator*(const Arbint & mul) const
{
bool operator==(const Arbint & equ) const;
bool operator<(const Arbint & less) const;
+
inline bool operator!=(const Arbint & equ) const
{
return result;
}
bool IsZero() const;
-
- //inline operator double() const {return double(AsDigit());}
+
+ inline operator double() const
+ {
+ double acc = 0;
+ for (int i = m_digits.size()-1; i >= 0; --i)
+ {
+ acc += (double)m_digits[i];
+ acc *= (double)UINT64_MAX + 1.0;
+ }
+ if (m_sign) acc *= -1;
+ return acc;
+ }
inline operator int64_t() const {return AsDigit();}
//inline operator int() const {return int(AsDigit());}
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);