The establishment and execution of java program

1. Start Eclipse and create a workspace at the same time. If it has been created, it will default.
2. New project: file-new-java project-enter a project name-complete.
3. Create a class file: select the project, right-click-create a new class-enter the class name-complete (note that the package can be created at the same time when creating a class, but the system uses the default package or default package.)
4. Enter the source file code in the editing interface. Note that all English capitalization and punctuation are all half-width in English. All statements end with a semicolon, and all parentheses must be used in pairs.
5. Save the file and run this program.
6. Check the console, if not through the window-try to call it out.
7. Font size adjustment:
Under Eclipse, window-preferences-general-appearance-font and color-basic-text font-size-OK.
8. Switch work space: file-switch work space-select your own folder or enter your own work space.
9. All projects, packages, and class files are in their own workspace. All projects and packages are displayed in folders under Windows.
10. In the main method (), the first letter of Sting in the parameter-String args is capitalized. Package name, item name can be Chinese characters, letters, underscores--, numbers are acceptable, but cannot start with numbers

.1: Binary to decimal

The value of any binary number is represented by its bitwise expansion.

For example: Convert the binary number (10101.11)2 into a decimal number.

(10101.11)2=124+023+122+021+120+12-1+1*2-2

=24+22+20+2-1+2-2=(21.75)10

2: Decimal system is sorted and converted to binary system

Convert a decimal integer to a binary integer using the "divide by 2 reciprocal method".

That is, divide a decimal integer by 2 to get a quotient and a remainder; then divide the quotient by 2 to get a quotient and a remainder;

And so on, until the quotient is equal to zero.

The inverse arrangement of the remainder obtained each time is the number of bits corresponding to the binary number.

Therefore, the result is the inverse arrangement of the remainder, which is:

37,10 (a5a4a3a2a1a0) 2 100 101) 2

3: Convert decimal fraction to binary fraction

The conversion of decimal decimals into binary decimals is by "multiplying by 2". That is to use 2 to multiply the decimal fraction successively,

Arrange the integer parts of the product obtained each time in the order of their appearance to obtain the corresponding binary decimal.

The process of converting the decimal fraction 0.375 into a binary fraction is as follows:

The final result: (0.375)10=(0.a1a2a3)2=(0.011)2

4: Convert hexadecimal to binary

Since 24=16, each hexadecimal number needs to be represented by a four-digit binary number, that is, each hexadecimal number is represented as a four-digit binary number.

Example: Convert hexadecimal number (B6E.9) 16 into binary number as:

B  6  E .  9

1011 0110 1110 . 1001

That is (B6E.9)16=(101101101110.1001)2

5: Convert binary numbers to hexadecimal

To convert a binary number into a hexadecimal number is to set the integer part of the binary number from right to left in groups of four digits, each group is a hexadecimal integer, if it is less than four digits, add 0 in the front;

The conversion of binary decimals to hexadecimal decimals is to convert the binary decimal part from left to right every four digits, and each group is a hexadecimal decimal.

When the last group is less than four digits, 0 should be used to make up the four digits.

Example: Binary number (1010101011.0110)2, converted into hexadecimal number:

0010 1010 1011 . 0110

2  A  B  . 6

That is: (10 1010 1011.0110)2=(2AB.6)16

Convert decimal to binary:

In easy-to-understand terms: Use this decimal to multiply by 2 until the decimal becomes an integer, and then the integer is converted to binary. Then, after multiplying by 2 a few times, you put the decimal point of the binary as sitting Just move a few places

Example: 0.75

0.75X2=1.5

1.5X2=3

Get the integer 3, now convert 3 to binary, as follows:

3(10)=》11(2)

Get the binary number: 11

Because I multiplied "2" twice just now, the decimal is as easy to understand as 2 digits on the left, and the final result: 0.11

Some decimals can never get an integer by multiplying by 2. If you want to keep 3 decimals, you can multiply by "2" three times. The decimals can be ignored and the integer part directly turned. It is binary, then shifted 3 bits to the left.

Guess you like

Origin blog.51cto.com/14980902/2545468