Eight basic types of Java:
六种数字类型(四个整数型,两个浮点型),一种字符类型,一种布尔型。
Details such as the following
1、整数:包含int,short,byte,long 2、浮点型:float,double 3、字符:char 4、布尔:boolean
The corresponding space and range such as the following
Basic Type |
Number of Bits |
Minimum Value |
Maximum Value |
Packing class |
Boolean |
No |
No |
No |
|
Char |
16-bit |
0 (Unicode) |
65535 (Unicode 2^16-1) |
Java.lang.Character |
Byte |
8-bit |
-128 |
+127 |
Java.lang.Byte |
Short |
16-bit |
-32768 ( -2^15) |
32767 (+2^15-1) |
Java.lang.Short |
Int |
32-bit |
-2147483648 ( -2^31) |
2147483647 (+2^31-1) |
Java.lang.Integer |
Long |
64-bit |
-9223372036854775808 ( -2^63) |
9223372036854775807 (+2^63-1) |
Java.lang.Long |
Float |
32-bit |
1.4E-45 (IEEE754 specified 32-bit content) |
3.4028235E38 (IEEE754) |
Java.lang.Float |
Double |
64-bit |
4.9E-324 (IEEE754) |
1.7976931348623157E308 (IEEE754) |
Java.lang.Double |
void |
|
|
|
|
The reference class is divided into 3 types (class type, interface type, and array type)
类类型:对类实例的引用;接口类型:对实现该接口的某个子类实例的引用;数组类型:对数组值的引用。在jvm中数组是个真正的对象。
————————————————————————
when programming, be careful to determine the range of values, directly using the appropriate type is better
Save development time with Float class, such as 32-bitThe underlying representation of float defines
IEEE 754 浮点单精度数字格式定义了存储浮点数的32位比特(bit)布局。各bit位详细为:"一位做符号位。八位留作指数,23位作尾数"。详细例如以下SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM当中:S = 符号位E = 指数M = 尾数
The conversion of floating-point and bit by float method
1. Floating point to bit
Float.floatToIntBits(float f) 将一个浮点数转成一个比特序列。
返回一个32位整数,表示你作为參数提供的浮点数的 IEEE 754 比特排列。
2. Bit-floating-point number
Float.intBitsToFloat(int bits)将传入整数作为一个比特序列,按float相应位置规定意义,转成一个浮点数。
Decimal Calculation description
java中小数数值计算无法保证绝对精准。仅仅能保证一定精度范围,比方,两个double数,不应该使用等号判定是否相等。由于相等的两个double数存储在计算机中可能不相等(计算机存储位数)。 尤其是除法。仅仅能保留一定范围的小数,精度取决于该类型在计算机的位数
Java Basic type (numeric range): Bottom representation definition of floating point, float calculation faster