python - 在 Python 中处理大数(16 位)的对数和反对数操作
问题描述
a = math.log(123456789123456789)
b = exp(a)
print(int(round(abs(b))))
输出:
123456789123457168
做anitlog后有数据丢失请告诉我如何避免它
解决方案
您可以使用Decimal
fromdecimal
模块来处理大量数字:
from decimal import Decimal
a = Decimal(123456789123456789).ln()
b = a.exp()
print(int(round(abs(b))))
Output:
123456789123456789
推荐阅读
- javascript - 如何在 NodeJs REST API 中从 mysql 获取特定数据
- c++ - 使用 par_unseq 时,我仍然可以依赖输出元素的顺序吗?
- java - 为什么 String concat(String) 方法的行为不同?
- javascript - IVH TreeView Twistie 没有触发与其绑定的功能
- android - 我可以让一些特定的布局被键盘重叠,而一些被adjustPan/resize影响吗?
- kubernetes - kubernetes watch 总是先显示项目列表吗?
- angular - 如何更改 Ag-grid 过滤器中的占位符文本?
- swift - 我无法快速通过协议传递值
- reactjs - 灯塔读取我的索引而不是 robots.txt
- c# - C# windows 应用程序构建未运行