A detailed comparison between C and C++ and Java in bytes for each data type

  • 2020-06-07 05:10:46
  • OfStack

Data type of C/C++ :

1, the integer

Turbo C:
[signed] int 2Byte// Signed number, -32768~32767
unsigned int 2Byte // Unsigned Numbers that can only represent integers from 0 to 65535

[signed] short [int] 2Byte

unsigned short [int] 2 Byte

long [int] 4 Byte

unsigned long [int] 4 Byte

Visual C++ 6.0:

[signed] int 4Byte
unsigned int 4Byte

[signed] short [int] 2Byte

unsigned short [int] 2 Byte

long [int] 4 Byte

unsigned long [int] 4 Byte
long int 4Byte

2. Solid type
float 4Byte
double 8Byte
long double 16Byte

3. Character
char 1Byte


Data type of Java:

1, the integer

byte 1 byte
short 2 bytes
int 4 bytes
long 8 words

2. Solid type

float 4 bytes
double 8 bytes

3. Character

char 2 bytes

4. The object type

Both arrays and String types in Java are interpreted as objects

5. Other

Boolean can be thought of as boolean 1/8 of a byte, or 1bit, but its size is unclear,

It depends on the compiler

1 byte =8bit means 8 zeros or ones for 1 unit in a computer

A Chinese character takes up 2 bytes, and an English character takes up 1 byte

Word length = word length = instruction length that the computer can process once

1: The computer USES byte type, 0000 '0001


Related articles: