You are on page 1of 2

#pragma once #include <iostream> class Integer { public: typedef unsigned __int32 Unit; static const unsigned MaxSize

= 32; protected: // Number of units that store data unsigned UnitLen; // If > 0, (SigBit - 1) is the offset of the highest set bit // If < 0, (-SigBit - 2) is the offset of the highest set bit, // or is -1 for Integer(-1) // Otherwise, Integer(0) signed SigBit; // Actual data Unit Data[MaxSize]; public: Integer(void); Integer(const Integer &); Integer(const Unit *, unsigned Count); Integer(const char *, unsigned Radix); Integer(const __wchar_t *, unsigned Radix); explicit Integer(signed long); void void bool bool long void void void void void void Not(); // 1's completement Neg(); // 2's completement ShiftLeft(); ShiftRight(); GetLong() const; Copy(const Unit *, unsigned Count); FromString(const char *, unsigned Radix); FromString(const __wchar_t *, unsigned Radix); MoveTo(Integer &); // Moves data and clears this ToString(char *, unsigned Radix) const; ToString(__wchar_t *, unsigned Radix) const;

unsigned GetUnitLength() const; unsigned GetSigUnitLen() const; Unit GetUnit(unsigned) const; bool GetBit(unsigned) const; bool bool bool bool IsZero() const; IsNegative() const; IsPositive() const; IsEven() const;

Integer & operator = (signed long); Integer & operator = (const Integer &); bool bool bool bool bool bool operator operator operator operator operator operator == != < > <= >= (const (const (const (const (const (const Integer Integer Integer Integer Integer Integer &) &) &) &) &) &) const; const; const; const; const; const; &); Integer &); Integer &); Integer &);

static static static static static

int Compare(const Integer void Add(const Integer &, void Sub(const Integer &, void Mul(const Integer &, void Div(const Integer &,

&, const Integer const Integer &, const Integer &, const Integer &, const Integer &,

static void static void // Computes static void

Integer & Quo, Integer & Rem); Mod(const Integer &, const Integer &, Integer &); Exp(const Integer &, const Integer &, Integer &); A ^ B mod C ExpMod(const Integer &, const Integer &, const Integer &, Integer &);

protected: void _Alloc(unsigned); void _ReAlloc(unsigned); void _DataShiftLeft(unsigned); bool _IsMax() const; bool _IsMin() const; void _FixSigBit(); friend std::ostream & operator << (std::ostream & Str, const Integer & Int); };

Signed char diapazonul -128 127

You might also like