擴充套件整體型別(在 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