gpt4 book ai didi

c++ - C++ 中最大范围的数据类型

转载 作者:行者123 更新时间:2023-11-28 01:33:58 28 4
gpt4 key购买 nike

我想要一个可以容纳 10^21 大小的数据类型。经过足够的搜索后,我得到了 unsigned long long 作为持有 18 * 10 ^ 18 左右的某个地方,这仍然不够。我该怎么办?

最佳答案

g++clang++ 和大多数平台都支持 __uint128__int128,它们有 128 位。您可以像使用普通整数一样使用它们,但它们往往有点 less compatible with the standard library .

这最多可以容纳 2^128 ~ 10^38

您也可以使用 doublefloat,但会失去精度。

或者您可以使用 BigInt library ,它允许任意精度的整数。

关于c++ - C++ 中最大范围的数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50225648/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com