Homework after class

Source: Internet
Author: User

    1. P22 hands-on brain:

S and T refer to not the same variable, nor the original data type.

An enumeration type is a reference type, and each of his specific values refers to a specific object, not the original data type.

2.P29 complement original code anti-code:

Anti-code, complement, the original code: in the computer, fixed-point number has 3 kinds of representations: the original code, anti-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 is the binary fixed-point notation, that is, the highest bit is the sign bit, "0" means positive, "1" is negative, and the remaining bits represent the size of the value. such as +7=00000111b,-7=10000111b.

The inverse code notation stipulates that the inverse code of a positive number is the same as its original code, and the inverse of a negative number is a bitwise negation of its original code, except for the sign bit. such as +7=00000111b,-7=11111000b;

The complement notation stipulates that the complement of positive numbers is the same as the original code, and that the complement of negative numbers is added to the minus 1 of the inverse code. such as +7=00000111b,-7=11111001b.

The data in Java programming is expressed in complement.

3.p35 Output value problem:

During program writing, if a variable with the same name occurs, the output value is judged according to its scope, and an output statement can only output the value corresponding to the variable with the same name in its scope.

4.P39:

Byte type data can be converted without loss of precision to the short type, while data of the Short,char type can be converted to type int without loss of precision, the data of type int is converted to float type and double type with precision loss, no precision loss when converted to long type, Float type data has no precision loss when converting to a double type, and long data has a precision loss when converting to a double type, so it is not possible to convert int type data to float and double types, and long data cannot be converted to a double type.

5.P41 hands-On Labs:

It is not accurate to use double type data to calculate the result.

6. P41 Reason:

1: This involves the conversion of binary and decimal.

n binary can be understood as: the power of the numerical x cardinality, for example, we are familiar with the decimal number 123.4=1x10²+2x10+3x (10 of the 0 power) +4x (10-1 power); the other binary is the same, such as the binary number 11.01=1x2+1x (2 0 Power) +0+1x ( 2-2 power) = 3.25 in decimal.

A value of type double takes 64bit, or 64 binary numbers, except that the highest bit represents the positive and negative sign, and the lowest bit is bound to have an error with the actual data (unless the actual data is exactly 2 of the n-th square).

The values we give, in most cases, require more digits than 64bit to be accurately represented (even in the case of infinite bits), and the double type has only 64bit, and the number of digits behind it is bound to bring an error, and the result of "mathematically accurate" cannot be obtained.

7.P44: Reason:

There is no loss of precision when converting data of type float to double type.

8.P47: Results:

Cause: +x+y indicates that the value of XY is output sequentially, and the "+" within "" can operate, representing the operator.

Homework after class

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.