Type conversions: small types to large type conversions

Source: Internet
Author: User

Conversion of small types to large types is done automatically, without the need for programmers to write extra code, which is the responsibility of the JVM.

PS: Automatic type conversion is also called an implicit type conversion.

Rules for automatic type conversion: symbol bits are automatically expanded, negative complement 1, positive complement 0

Automatic type conversion consists of the following:

1.byte->short->int->long->double->

Data of type 2.int and char can be converted to each other automatically in some cases

Do a test.

The int type is 32 bits, the highest bit is the sign bit, and the remaining 31 bits are the mantissa.

The long type is 64, the highest bit is the sign bit, and the remaining 63 bits are the mantissa. PS: mantissa: Precision value.

When the int type is converted to a long type, because it is a negative number, the sign bit complements 32 bits of 1.

Type conversions: small types to large type conversions

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.