Data type: Built-in, reference;
Eight basic types: 6+1+1:6, 1-character, 1-type Boolean
1>byte 8-bit 1-byte, -128~127,
2>int 32-bit 4-byte, minimum value is-2,147,483,648 ( -2^31), maximum value is 2,147,483,647 (2^31-1)
3>long 64-bit 8-byte, minimum value is-9,223,372,036,854,775,808 ( -2^63), maximum value is 9,223,372,036,854,775,807 (2^63-1)
4>float single precision, 32-bit
5>double Double Precision 64 bit
6>short 16 bit, minimum value is-32768 ( -2^15), maximum value is 32767 (2^15-1)
The 7>char 16-bit (Unicode encoding) minimum value is \u0000 (that is, 0); The maximum value is \uffff (that is, 65,535);
Conclusion:
1. Data type conversion to a floating-point type can have a loss of precision
2.byte short int long float double can be converted directly to each other (strong turn)
public class Testdouble {public static void Main (String args[]) { System.out.println ("0.05 + 0.01 =" + (0.05 + 0 .)); System.out.println ("1.0-0.42 =" + (1.0-0.42)); SYSTEM.OUT.PRINTLN ("4.015 * =" + (4.015 *)); System.out.println ("123.3/100 =" + (123.3/100));} }
The result is:
Reason:
When the value of the double type is added and reduced, Numeric values are converted to binary values such as 10001.10010110011 This means that the expression is added and reduced, but in the conversion to binary code representation, the number of bits stored in the fractional part will not be enough, that is, infinite loop decimal, which is the main cause of the micro-gap.
Data types and Conversions