引言
何为高精度
高精度,作为算法竞赛中常见又不常见的三个字,广泛出现在大量题目中。高精度着实是比较少用的,因为本身高精度写起来麻烦,处理起来速度也慢,所以很多题目只会爆int,很少爆long long。
但是为什么要学高精度呢,因为总有那么些~~良(du)心(liu)~~出题人会故意卡long long,所以高精度的学习仍然是有必要的。
什么情况要用高精度
下列情况会必须使用高精度:
1、有符号整数超过(2147483647就会爆int)
2、无符号整数超过(4294967295就会爆unsigned int)
3、浮点数:浮点数比较复杂,按照IEEE754标准,如果在不考虑精度的情况下,double的最大值可以达到这个范围(为什么说不考虑精度呢,这就涉及到IEEE754标准中,浮点数是按照阶码(就是对应乘二的幂)乘上尾数得到的,详情看基本知识一栏)
4、其他奇奇怪怪的情况(可以看下面的系数一题)
热身
基本知识
int128 & float128
入门篇
高精度的表示法
高精度加法
高精度减法
进阶篇
高精度乘法
高精度除法
终极篇
使用FFT(快速傅里叶变换)进行高效的高精度乘法
使用NTT(离散数论变换)进行高效的高精度乘法
引用
[1]:https://www.h-schmidt.net/FloatConverter/IEEE754.html
许可证
本文章由FDL1.3(GNU Free Documentation License)作为许可,本文章中所有示例代码由GPL3.0(GNU General Public License)作为许可
FDL1.3
Copyright (C) 2022 Andy Shen.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".GPL3.0
Copyright (C) 2022 Andy Shen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.