跳到正文

个人记录

跟你烦人的高精度说拜拜!-------__int128

wzh041500约 1 分钟
原文
文章信息与版本

文章信息

发布
2023年10月13日
收录
2025年12月12日
更新
2026年11月15日
篇幅
约 1 分钟

版本

  1. v1当前

你是否正在被高精度折磨得痛不欲生,推荐食用__int128

注:

1.最大存储范围,约+/- 1e39

2.__int128只能参与四则运算,不能使用cin,cout,frintf,scanf等,需自己写函数来读写

3.除此以外,与int,long long用法类似

.

.

.

具体操作(已测试,可放心食用):

C++
#include<bits/stdc++.h>
using namespace std;
__int128 a,b;
char c;
__int128 read()
{
	__int128 res=0;
	string s;
	cin>>s;
	int i=0;
	bool f=1;
	if(s[0]=='-')f=0,i++;//注意负数
	for(i;i<s.size();i++)
	{
		res*=10;
		res+=s[i]-'0';
	}
	if(f)return res;
	return -res;
}
void print(__int128 num)
{
	bool s=1;
	if(num<0)
	{
		s=0;
		num=-num;//注意负数
	}
	if(s==0)cout<<'-';
	if(num>9)print(num/10);
	cout<<char(num%10+'0');
}
int main()
{
	a=read();
	b=read();
	print(a+b);
}
原文
抓取于
  1. wzh041500

    ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้ 。 ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้

  2. wzh041500

    ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้ ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้

  3. wzh041500

    ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้

  4. wzh041500

    ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้

  5. wzh041500

    ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้

  6. wzh041500

    qp

  7. wzh041500

    qp