自己的高精度库,C++,请求指教
通过网盘分享的文件:prec.hpp链接: https://pan.baidu.com/s/1slmrlA6cnXTZXKPD7C7esA?pwd=oier 提取码: oier
通过网盘分享的文件:calc_pi.cpp等2个文件
链接: https://pan.baidu.com/s/18ETWK49dn3Nh9KxSA3QCTw?pwd=oier 提取码: oier
计算pi到1000000位数需要30秒钟
谁教你这么写代码的? 要用clang++编译 Ickiverar 发表于 2026-1-9 22:21
谁教你这么写代码的?
winget install llvm.llvm
clang++ -o pi_calc.exe pi_calc.cpp -O3 本帖最后由 Yi_Zhi_OIer 于 2026-1-10 13:14 编辑
这个有一个bug,乘法结果>80000000位会出现故障,计算结果不对 c++不是这个样子的。你应该通读cppreference,然后就会发现两个下划线开头的identifier/typename是标准和编译器保留的:
Identifiers
Identifiers that appear as a token or preprocessing token (i.e., not in user-defined-string-literal like operator ""id)(since C++11) of one of the following forms are reserved:
in the global namespace, identifiers that begin with an underscore
identifiers that contain a double underscore or begin with an underscore followed by an uppercase letter, except the following identifiers:
除非标准明确说明(Predefined_macros)你作为用户是无权使用的。
我拒绝安装clang,而你作为cpp程序员,有责任写出符合标准的代码。 我一个搞竞赛的,信息学(OI)。__int128很常用,而且两个下划线GNU MP之类的也用 Ickiverar 发表于 2026-1-10 13:53
c++不是这个样子的。你应该通读cppreference,然后就会发现两个下划线开头的identifier/typename是标准和编 ...
再说了编译问题是MSVC没有__int128支持 而且__preclib_hi完全没用,纯属测试而已。__precn_struct之类的编译也没有问题。 Yi_Zhi_OIer 发表于 2026-1-10 13:56
我一个搞竞赛的,信息学(OI)。__int128很常用,而且两个下划线GNU MP之类的也用 ...
__int128 不是C++标准里的类型.只有gcc和clang才支持.
稍微做一些typedef,就可以消除编译器的差异性/