Basics of Java grammar, after-school practice

Source: Internet
Author: User

2. binary representation of numeric values

After-school exercise: read the corresponding textbook, or use the Internet search engine, to find out the anti-code, complement and the original code of the concepts, and then write a sample program, the positive numbers, negative numbers for a variety of bit operations, observe the output, and the results of the manual calculation, to see the number in Java is the above-mentioned Code.

answer: within the computer, the fixed-point number has 3 seed notation: Original code, inverse code, and Complement. Anti-code is a kind of numerical storage, but because the complement is more effective in the representation of the number in the computer form, so most computers generally do not use Anti-code representation number.

The original code: binary fixed-point notation, that is, the highest bit is the sign bit, "0" is positive, "1" is negative, the remaining bits represent the size of the Value.

Anti-code: the inverse code of positive number is the same as its original code, and the inverse code of negative number is the inverse of its original code, except the sign bit.

Complement: the complement of positive number is the same as its original code, the complement of negative is in its inverse code to add 1;

Java is the use of complementary of the

3. scope of the variable

Each variable has a "valid" area (called a "scope"), out of which the variable will no longer be valid.

Enum type is a reference type! An enumeration is not part of the original data type, and each of its specific values refers to a specific object. The same value refers to the same object.

You can use the "= =" and the Equals () methods to directly compare the values of the enumeration variables, in other words, the result of the "= =" and the Equals () methods are equivalent for variables of enum Types.

6. Why is the numeric value of a double type not "mathematically accurate"?

First we have to discuss this problem from the computer itself. The computer does not recognize any data other than binary Data. No matter what programming language we use, and in what programming environment, we must first translate the source program into binary machine code before it can be recognized by the Computer. In fact, floating-point numbers are not suitable for precise calculations and are suitable for scientific calculations. float and double are used to denote numbers with a decimal point, and these numbers are stored in the form of scientific notation. When a number such as 50.534, converted to scientific notation in the form of 5.053e1, its decimal point moved to a new position (that is, Floating) visible, floating point is used for scientific calculation, for accurate calculation is too inappropriate!

Basics of Java grammar, after-school practice

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.