超过芯片组允许的最大数据类型.C++
Exceeding largest datatype allowed on chipset. C++
我有一些数学超过了c ++长数据类型。解决这个问题的最佳方法是什么?我正在嵌入式芯片组上做基本的数学+,/和*。 我在一个循环中将数字相加,然后将大数字除以。
通常,一个long
(与long int
相同(的大小至少为4个字节。但是,请自己检查。如果您发现long long int
的字节数超过long int
,并且您的值不超过long long int
中可存储的最大值,请使用该值。使用此标头中的 #include <limits>
和 Use 函数来确定整数类型中可存储的最大值。
例如
#include <limits>
#include <iostream>
int main()
{
std::cout << std::numeric_limits<int>::max() << std::endl;
std::cout << std::numeric_limits<long int>::max() << std::endl;
std::cout << std::numeric_limits<long long int>::max() << std::endl;
}
这在我的机器上输出以下内容:
2147483647
9223372036854775807
9223372036854775807
但是,如果您的值也超过了可以存储在long long int
中的值,请使用大数字库。
相关文章:
- 防止主数据类型C++的隐式转换
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 在C++中打印指向不同基元数据类型的指针的内存地址
- C++浮点数据类型和字符串数据类型无法子到模板函数中
- 如何计算数据类型的范围,例如int
- C++中数据类型修饰符的顺序
- C++LinkedList问题.数据类型之间存在冲突?没有匹配的构造函数
- 特定数据类型的模板类
- 具有多个模板的模板函数,用于特定数据类型(如字符串)?
- 有没有办法提示用户使用哪种数据类型作为模板 c++
- int数据类型的指针指向的是什么,如果是一个类的私有数据成员,我们创建了该类的两个对象?
- 时间复杂度 当具有复合数据类型(如元组或对)时?
- 如何获取C++字符数据类型的地址
- 将复杂的非基元C++数据类型转换为 Erlang/Elixir 格式,以使用 NIF 导出方法
- 构造智能点数据类型以及普通数据类型的通用方法
- 如何使映射键具有两种不同的数据类型?
- 数据类型"struct seq<0, 1, 2>{}"含义是什么?
- 如何在不破坏现有应用程序的情况下更改 API 中 stl 容器的数据类型?
- Static_cast转换为错误的数据类型,但结果仍然正确?
- 使用 Boost.Spirit 解析具有混合数据类型的 OBJ 文件?