The basic role of data types and data type classification

The basic role of data types and data type classification

effect

  1. In order to limit the data stored in variables (it is at least compatible).
  2. In order to limit the space occupied by variables

classification

Data types can be divided into the basic data types and the reference data type. Basic data types can be divided into integer, floating point, character, and Boolean types, reference data types can be divided into string, array, null and objects.

Integer

Integer can be divided into byte, short, int, long four kinds, distinguished by their occupied bytes, byte occupies one byte, in the range of -128 ~ 127, short two bytes, in the range - 2 ^ 15 ~ 2 ^ 15-1, int occupies four bytes, in the range -2 ^ 31 ~ 2 ^ 31-1, long 8 bytes, in the range -2 ^ 63 to 2 ^ 63 -1 integer defaults to int.

Float

Float is divided into two respectively were float, double, they share four bytes and bytes are eight-byte character constants default to a double.

Character

Keyword character char is 2 bytes, ranging from 0 to 2 ^ 8, typically lookup table from ASCII, GBK table and UTF-8. Lowercase letters 97 to 97 + 25, capital letters 65 to 25 + 65, 48 + 48 to figures 9.

Boolean

Only two Boolean values ​​true and false, not the explanation

These are the basic data types are described, it being the first reference data types do introduced.

Note: In the figures and decimal arithmetic, byte type short type final addition result obtained is of type short, short int type plus the result type final int type, int result type plus last long type derived type long , long type plus fioat type final the result is a float, a float type doubule plus final the result is double. range into a small big can be, but a wide range of small-scale strong turn may there is a loss.

 

Published 13 original articles · won praise 1 · views 246

Guess you like

Origin blog.csdn.net/Yi_nian_yu_dian/article/details/104203201