您的位置:首页 > 编程语言 > C语言/C++

Java/C#/C/C++基本数据类型一览

2012-04-28 11:17 465 查看
一、Java



几点说明:

1、官方文档的信息:sun's Data Types introduction:

byte: The byte data type is an 8-bit signed two's complement integer

short: The short data type is a 16-bit signed two's complement integer

int: The int data type is a 32-bit signed two's complement integer

long: The long data type is a 64-bit signed two's complement integer

float: The float data type is a single-precision 32-bit IEEE 754 floating point

double: The double data type is a double-precision 64-bit IEEE 754 floating point.

char: The char data type is a single 16-bit Unicode character

boolean: The boolean data type has only two possible values: true and false.

Use this data type for simple flags that track true/false conditions. This data type represents one bit of information,

but its "size" isn't something that's precisely defined.


2、《深入JAVA虚拟机》(第二版)的信息:

(1)在虚拟机里boolean在编译成字节码时会用int或byte来表示。false用整数0表示,true用非零整数表示。涉及boolean的操作是用int进行的。boolean数据是当成byte数组进行访问的。

(2)JAVA虚拟机中,基本的数据单元是字(word)大小由虚拟机的设计而定。一般为32位。虚拟机的局部变量和操作数栈都是按照字来字义的。

二、C#



几点说明:

1、我自己的测试信息:

sizeof(bool): 1

Marshal.SizeOf(bool): 4

Marshal.SizeOf(byte): 1

2、官方文档的信息:

Marshal.SizeOf 在封送类型后返回大小,而
sizeof 返回公共语言运行时分配的大小(包括所有填充)。

三、C/C++

参见:/article/11073558.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: