📄 mathint.h
字号:
//The definition of mathInt,range:-2^1024--->2^1024;
#ifndef _CLASS_MATHINT_
#define _CLASS_MATHINT_
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<time.h>
using namespace std;
const int BASE=256;
const int VSIZE=128;
class mathInt
{
private:
bool sign;
vector<int> coeff;
public:
mathInt(bool isPos=1){sign = isPos;coeff.resize(VSIZE); }
mathInt(int integer);
mathInt(bool isPos,vector<int> v){ sign = isPos; coeff = v; }
~mathInt(){}
void set_coeff(bool isPos,int size);//set size nonzero coefficients;
bool get_sign()const{ return sign;}
int length()const;
const vector<int> get_coeff()const{ return coeff;}
mathInt abs()const;
void display()const;
void OutToFile(char* name)const;
void OutToString(char* name,bool flag)const;
bool is_odd()const;
bool is_pos()const;
//overload operator
int operator [](int i)const;
mathInt operator - ()const{ return mathInt(!sign,coeff);}
bool operator < (mathInt const& a)const;
bool operator <=(mathInt const& a)const;
bool operator ==(mathInt const &a)const;
bool operator ==(int const& a)const;
mathInt operator >>(int n)const;//keep the original mathInt,return (*this)*BASE^n;
void operator = (mathInt const & a);
void operator = (int const & n);
mathInt operator +(mathInt const& a)const;
mathInt operator +(int const& a)const;
mathInt operator -(mathInt const& a)const;
mathInt operator -(int const& a)const;
mathInt operator *(int n)const;
mathInt operator *(mathInt const& a)const;
mathInt operator /(mathInt const& a)const;
mathInt operator /(int const & a)const;
mathInt operator %(mathInt const& a)const;
};//class mathInt, the num may be negative
const mathInt ZERO;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -