目前支持正混用乘法,和同符号加法,减法懒得写了;
用vec封装大数组,类里面不包含指针,所以不用重写析构函数和复制构造函数。
用法:
赋值:直接用字符串,或者c自带的类型给bigint赋值
#include <bits/stdc++.h>
using namespace std;
class bigint{
vector<int> digits;
const int WIDTH = 8;
const int W = pow(10, WIDTH);
int sign = 1;
/* bigint的构造器 */
bigint& constructor(string s){
/* 舍去小数点处理 */
auto p = s.find('.');
if(p != string::npos) s = s.substr(0, p);
/* 空字符串处理 */
if(s == "") {
digits.push_back(0);
return *this;
}
/* 符号处理 */
if(s[0]=='-'){
sign = -1;
s = s.substr(1);
}
digits.clear();
/* 将整数以8为长度截断存入vector */
for(int r = s.size(); r > 0; r -= WIDTH){
int l &