Java basic type

Source: Internet
Author: User

In Java, there are eight basic data types:

1) The 31 Power of int 4 bytes (byte)-2 to the 31 power of 2-1

2) short 2 bytes (byte)-the 15th power of 2 to the 15th power of 2-1

3) long 8 bytes (byte)-power 63 of 2 to power 63 of 2-1

4) byte 1 byte-the 7th Power of 2 to the 7th Power of 2-1

5) float 4-byte 7-bit valid number

6) double 8-byte 16-bit valid number

7) char 2 bytes (byte)

8) boolean

1 byte = 8 bits

Type ------- symbol digit ------------- exponent digit -------------- tail digit ----

Float --- 31st (1bit) --- 30-23 (8bit) ---- 22-0 (23bit)

Double -- 63rd bits (1bit) --- 62-52 bits (11bit) --- 51-0 bits (52bit)

The value range mainly depends on the index:

The float index is 8 bits (2 ^ 8). Because it is signed, the corresponding index range is-128 ~ 128.

The index of double has 11bit (2 ^ 11). Because it is signed, the corresponding index range is-1024 ~ 1024.

The index range of the float index is-128 ~ 128, so the value range is-2 ^ 128 to 2 ^ 128, which is approximately-3.4E38-+ 3.4E38

Precision (valid number) mainly depends on the ending number:

The ending number of float is 23bit, corresponding to 7 ~ 8-bit decimal number, so some compilers for valid numbers are 7-bit, and some are 8-bit.

 

Common Data Types in C Language

1) int 2 bytes

2) short 2 bytes

3) long 4 bytes

4) unsigned 2 bytes

5) float 4 bytes

6) double 8 bytes

7) Char 1 byte

8) boolean

 

Common Data Types in C ++

1) bool

2) char 1 byte

3) wchar_t 2 bytes

4) short 2 bytes

5) int 2 bytes

6) long 4 bytes

7) float 6-digit valid number

8) double 10-digit valid number

9) long double 10-digit valid number

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.