ในบทช่วยสอนนี้ เราจะพูดถึงโปรแกรมเพื่อทำความเข้าใจประเภทอินทิกรัลแบบขยายใน 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