Java base floating-point types

Source: Internet
Author: User

1. Floating-point types are used to represent decimal data types.

2, floating point number principle: that is, the binary scientific counting method.

3. The floating-point type of Java has float and double two kinds.

4. The result of the Java default floating-point type calculation is a double type, and the literal is also a double type.

1, decimal floating point number scientific counting method: 219345 = 2.19345* (10^5)

2, binary floating point number scientific counting method: 10111 = 1.0111* (2^100)

1, Float type Total 32 bits, 1 bit is sign bit, exponent 8 bit, mantissa 23 bit.

2, float precision is 23 bits (that is, can accurately express the number of 23 bits, more than is intercepted).

Decimals are expressed in the mantissa length, such as the accuracy of pi=3.1415 is 4 bits.

3. Float stores data in a range larger than int, but with less precision than int because the precision of int is 31 bits.

1, double type, 1-bit sign bit, 11-bit exponent, 52-bit mantissa.

2, double range is much larger than long, but double precision is inferior to long.

Floating-point arithmetic is real arithmetic, because the computer can only store integers, so the real numbers are approximate, so floating-point arithmetic is very slow and there is error.

Placeholder Summary:

Character type: char:2 bytes
Integer: byte:1 bytes
Shot:2 bytes
Int:4 bytes
Long:8 bytes
Real: Float:4 bytes
Double:8 bytes
Boolean: Boolean: One-byte
One of these bytes consists of 8 bits

Java base floating-point types

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.