Variables related to Java

Source: Internet
Author: User

A variable is a variable value within a range.

Points:

Data type (determines the type of the variable's value)

8 bits in a byte, each bit storing 0101 such binary complement is used for data, the first bit of a byte data type is the sign bit, which indicates positive or negative.

Data type byte short int long float double char Boolean

Number of bytes 1 2 4 8 4 8 2 1

stored in the computer is the complement of data, the 1th bit is the sign bit, the complement of negative numbers equals its inverse code +1, so the range is:

-2^8~2^7-1 ....... ........

About Precision:

What precision?

When using the complement, the first bit of the first byte represents the sign bit, which represents the positive or negative, which may represent precision. Therefore, when the long data type directly using the short data type to accept the error, you may lose precision, that is, the previous byte is discarded.

The operation of the variable:

The same data type, which is for its complement operation, needs to change the accepted data type in order to get the error data when the number of complementary digits exceeds the number of in-situ numbers.

With different data types, the small data types are converted to large data types and then manipulated using large data types. The generally obtained values are of a large data type. This is an implicit conversion of variables.

Forced type conversion (large turn small)

is to intercept the large type of the following bytes so that the number of bytes is equal to the number of small bytes, so that the small range can be accepted.

The problem of casting possible loss accuracy.

Variables related to Java

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.