扩展整体类型(在 C/C++ 中选择正确的整数大小)
本教程中,我们将讨论一个程序,了解 C/C++ 中的扩展整体类型。
C 中的数据类型定义得相当随意。它们的范围值根据编译器是 32 位还是 64 位而变化。要指定要程序中使用的编译器范围,我们使用 intN_t.
示例
#include <iostream>
using namespace std;
int main(){
uint8_t i; //mentioning the bit to be 8
i = 0;
cout << "Minimum value of i\t: "<<< (int)i << endl;
i = 255;
cout << "Maximum value of i\t: "<< (int)i << endl;
//moving beyond the given bit will result in garbage value
i = 2436;
cout << "Beyond range value of i\t: " << (int)i << endl;
return 0;
}输出
Minimum value of i : 0 Maximum value of i : 255 Beyond range value of i : 132
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP