📄 clongint.h
字号:
// This program is a class for long number computing with no limit.
#ifndef MELON_CLONGINT_H
#define MELON_CLONGINT_H
//struct tagCLONGINT_DIVIDERESULT;
typedef struct tagCLONGINT_DIVIDERESULT DIVIDERESULT, FAR * LPDIVIDERESULT, * PDIVIDERESULT;
// Definition the CLongInt class
class CLongInt
{
protected:
CString m_csInt;
BOOL m_bSign;
static const char sCharSet[];
public:
// Initialize Functions
CLongInt();
CLongInt(long nNum);
CLongInt(const char *lpszNumStr);
CLongInt(const CString & cs);
CLongInt(const CLongInt & li);
virtual ~CLongInt();
public:
// I/O Function
CString GetNumString() const;
public:
// Calc Operator Overload
CLongInt & operator = (long nNum);
CLongInt & operator = (const CLongInt & li);
CLongInt operator + (long nNum) const;
CLongInt operator + (const CLongInt & li) const;
friend CLongInt operator + (long x, const CLongInt & y);
CLongInt operator - (long nNum) const;
CLongInt operator - (const CLongInt & li) const;
friend CLongInt operator - (long n, const CLongInt & li);
CLongInt operator - () const;
CLongInt operator * (long n) const;
CLongInt operator * (const CLongInt & li) const;
friend CLongInt operator * (long n, const CLongInt & li);
friend DIVIDERESULT Div(const CLongInt & liBei1, const CLongInt & liChu1);
//CLongInt operator / (const CLongInt & liChu) const;
CLongInt operator += (long n);
CLongInt operator += (const CLongInt & li);
CLongInt operator -= (long n);
CLongInt operator -= (const CLongInt & li);
CLongInt operator *= (long n);
CLongInt operator *= (const CLongInt & li);
// Basic Compare Operator Overload
BOOL operator > (long n) const;
BOOL operator < (long n) const;
BOOL operator >= (long n) const;
BOOL operator <= (long n) const;
BOOL operator == (long n) const;
BOOL operator != (long n) const;
BOOL operator > (const CLongInt & li) const;
BOOL operator < (const CLongInt & li) const;
BOOL operator >= (const CLongInt & li) const;
BOOL operator <= (const CLongInt & li) const;
BOOL operator == (const CLongInt & li) const;
BOOL operator != (const CLongInt & li) const;
private:
BOOL IsNum(const char * lpszNumStr) const;
CString ToRegularNumStr(const char * lpszNumStr) const;
inline int GetLeft(int x) const;
};
// Definition the Exception class
class CLongIntException : public CException
{};
class CLongIntIsNotNumberException : public CLongIntException
{};
class CLongIntDivException : public CLongIntException
{};
// Definition the DivideResult struct
struct tagCLONGINT_DIVIDERESULT
{
CLongInt liQuotient;
CLongInt liModulus;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -