Java, as a strongly typed language, means that each variable will have a specific type, there are 8 basic types of Java, there are 4 types of integers (byte, short, int, long), two floating-point types (float, double), 1 character types (char) and a Boolean (Boolean), it is worth noting that although string strings are very common, it is not a basic type.
Second , floating-point type (next integral type)
Floating-point types represent numbers with decimal parts, and Java includes float and double two floating-point data, float is called a single-precision floating-point number, and double is called double-precision floating-point. According to the float class source can be learned that the maximum value of float is 0x1.fffffep+127f (3.4028235e+38f), The minimum value is 0x0.000002p-126f (1.4e-45f), the length is 4 bytes, and the double precision is twice times of float and the maximum value is 0x1.fffffffffffffp+1023 (1.7976931348623157e+308) With a minimum value of 0x0.0000000000001p-1022 (4.9e-324) and a length of 8 bytes.
Since the effective number of floats is only 6~7 bit, can not meet the needs of daily development work, so in the development process most of the use of double type data, and the type of float data need to add F or F after the value, For example, 2.13F and 3.14f, while floating-point types are double by default, such as 2.13 and 3.14, and of course can be followed by D or D. In hexadecimal notation, the notation for floating-point types is 0x1.****p*, presumably because E is a numeric representation in hexadecimal, so replace it with P.
It is also worth noting that floating-point data does not apply to financial calculations that prohibit rounding errors, mainly because floating-point values are represented by binary systems, so it is not possible to accurately represent fractions, and it is recommended to use the BigDecimal type without error.
Read the source found a more interesting place:
IsNaN (), this method seems to be useless Ah, API description parameter is a non-numeric time to return true, but if the parameter is non-numeric, the compilation error will be reported.
Static public boolean IsNaN (double v) { return (v! = v);}
Looking back, Java restudying (iv): floating-point type of Java basic data type