表示整數、字元和布林值的算術型別合稱為整型(integraltype)
整型int、short和long都預設為帶符號型。要獲得無符號型別必須指定該型別為unsigned,比如unsigned long。
unsignedint型別可以簡寫為unsigned,也就是說,unsigned後不加其他型別說明符就意味著是unsignedint。
一位元組表示八位,即:1byte =8 bit;
int 4byte 32 bit
signed 4byte 32 bit 2^31-1 ~ -2^31 即:2147483647 ~-2147483648
unsigned 4byte 32 bit 0 ~ 2^32-1 即: 0 ~ 4294967295
long 4byte 32bit
double 8byte 64 bit 1.79769e+308 ~2.22507e-308
long double 12byte 96bit 1.18973e+4932 ~ 3.3621e-4932
float 4byte 32bit 3.40282e+038 ~1.17549e-038
從長整型資料取位元組
1 移位 佔記憶體,移植性一般 2 強制轉換 方便,移植性差 3 巨集定義 易讀,移植性好 define tobyte x,i char x i x表示資料,i表示位元組號 4 聯合體 union byte value 訪問時直接,方便,如value.dw,value.byte.b0等 5 聯合體 ...
C語言中各種整型型別所佔位元組數
平台 64位編譯器 linux gcc includemain 結果 char a 1 char b 8 short int c 2 int d 4 unsigned int e 4 float f 4 double g 8 long h 8 long long i 8 unsiged long j...
C 字串到位元組陣列,位元組陣列轉整型
int num 12345 string num1 convert.tostring 12345,16 byte bytes bitconverter.getbytes num 將int32轉換為位元組陣列 num bitconverter.toint32 bytes,0 將位元組陣列內容再轉成in...