https://github.com/nemo2011/cpp-high-accur
C++ 高精度算法
https://github.com/nemo2011/cpp-high-accur
Last synced: 10 months ago
JSON representation
C++ 高精度算法
- Host: GitHub
- URL: https://github.com/nemo2011/cpp-high-accur
- Owner: Nemo2011
- Created: 2022-10-05T02:10:57.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-06T01:02:42.000Z (almost 4 years ago)
- Last Synced: 2025-04-06T04:11:25.436Z (over 1 year ago)
- Language: C++
- Size: 12.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C++ 高精度算法整理
- 支持加、减、乘、除、取余
- 支持输入输出
- 支持结构体
## 如何使用?
拷贝 `lib` 下的 `haa.h` 到你的编译器库存储的地方。然后就可以使用了!
## 举个例子
``` cpp
#include
#include
#include "lib/haa.hpp"
using namespace std;
using namespace haa;
int main() {
/**
* $> ./test
* 2 3
* ..~~~ 2 3
* ----- 5
* $>
*/
string s1, s2; // -----1
cin >> s1 >> s2; // |输入|1
BigINT n1 = BigINT(s1), n2 = BigINT(s2); // -----1
BigINT sum = n1 + n2; // |求和|2
for (BigINT i = ONE; !i.big(n1); i = i.plus(ONE)) { // -----3
cout << "."; // | |3
} // | |3
for (BigINT i = ONE; !i.big(n2); i = i.plus(ONE)) { // | |3
cout << "~"; // | |3
} // |循环|3
cout << " " << n1.stringify() << " " << n2.stringify() << endl;// |输出|3
for (BigINT i = ONE; !i.big(sum); i = i.plus(ONE)) { // | |3
cout << "-"; // | |3
} // | |3
cout << " " << sum.stringify() << endl; // -----3
return 0;
}
```
## License
`MIT License`