在做這三個程式語言的互轉時,資料的型別是很重要的,自己找一些網頁來存做自己的筆記,以便自己的程式工作!
使用C語言撰寫商用應用程式時,以32位元處理器為主,表列32Bit資料範圍:
Type Name | 位元長度 | Range of Values |
char | 8 | –128 to 127 |
unsigned char | 8 | 0 to 255 |
short | 16 | –32,768 to 32,767 |
unsigned short | 16 | 0 to 65,535 |
int | 32 | –2,147,483,648 to 2,147,483,647 |
long | 32 | –2,147,483,648 to 2,147,483,647 |
unsigned long | 32 | 0 to 4,294,967,295 |
float | 32 | 3.4E +/- 38 (7 digits) |
double | 64 | 1.7E +/- 308 (15 digits) |
Microsoft Visual C++另外提供的型態如下表:
Type Name | 位元長度 | Range of Values |
__int8 | 8 | –128 to 127 |
__int16 | 16 | –32,768 to 32,767 |
__int32 | 32 | –2,147,483,648 to 2,147,483,647 |
__int64 | 64 | –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
unsigned __int64 | 64 | 0 to 18,446,744,073,709,551,615 |
在Java中呢?
Java語言所定義的基本資料型別有
Type Name | 位元長度 | Range of Values |
boolean | 1 | true或false |
byte | 8 | -128 ~ 127 |
short | 16 | -32768 ~ 32767 |
char | 16 | Unicode characters |
int | 32 | -2147483648 ~ 2147483647 |
long | 64 | -9223372036854775808 ~ 9223372036854775807 |
float | 32 | +-3.4028237*10+38 ~ +-1.30239846*10-45 |
double | 64 | +-1.76769313486231570*10+308 ~ 4.94065645841246544*10-324 |
Java的資料型態裡沒有unsigned。