Home  >  Article  >  Java  >  The difference between double and float in java

The difference between double and float in java

尚
Original
2019-12-02 14:51:345297browse

The difference between double and float in java

The difference between double and float in java: (Recommended: java video tutorial)

Single precision floating point number (float) and double precision float The difference between points (double) is as follows:

(1) The number of bytes occupied in the memory is different

Single-precision floating point numbers occupy 4 bytes in the machine

Double-precision floating-point numbers occupy 8 bytes in the machine

(2) The number of valid digits is different

Single-precision floating-point number has different valid digits 8-bit

Double-precision floating-point number, 16-bit valid digits

(3) The range of numbers that can be represented is different

Representation of single-precision floating point Range: -3.40E 38 ~ 3.40E 38

Double precision floating point representation range: -1.79E 308 ~ 1.79E 308

(4) The processing speed in the program is different Generally speaking, the CPU processes single-precision floating-point numbers faster than double-precision floating-point numbers

For more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of The difference between double and float in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]