Java vs. binary conversion

Source: Internet
Author: User

1. Java Features: Portability, object-oriented, open source, robustness

2. JDK,JRE,JVM:

A) JDK:Java Development Kit Java Runtime package (includes JRE and JVM)

b) JRE:Java Runtime Environment Java Run environment (contains JVM)

c) JVM:java virtual machine

3. about configuring environment variables:

A) path: files needed for Java compilation

b) classpath: Find the path to the . class file for your virtual machine

4 . Keywords cannot be used as identifiers; goto and const are java keywords

5. Java data type:

A) basic data type:

I. integral type: Byte, short,int,long

II. Float type: float,double

III. character type: char

Iv. Boolean type: Boolean

b) Reference data type: Class, interface, array, etc.

6,1 byte = 8 bit

7, Byte:1char:2 byte int:4 byte long :8float:4 byte

8. escape characters: \ n : newline \ t : space \ r : Enter

9. Float Flo = 3.14f

10, long lo = 123456789l

11, into the system:

(1) decimal ----binary:

such as: decimal number to binary binary :

The remainder

Divide by 2 50..............0

Divide by 2 25..............0

Divide by 2 12..............1

Divide by 2 6................0

Divide by 2 3................0

Divide by 2 1................1

Divide by 2 0................1

inverse fetch remainder: binary number: 1100100

(2) binary--- decimal:

such as: binary number 1100100 to decimal

1 1 0 0 1 0 0

1*2 ' 6 1*2 ' 5 0*2 ' 4 0*2 ' 3 1*2 ' 2 0*2 ' 1 0*2 ' 0

(starting from the single digit, 2 of the 0- Time Square)

64 32 0 0 4 0 0

The result would be to add a decimal number of: 100

(3) Binary turn octal:

such as binary number 1100100 to eight binary:

XX1

(Start in Bits, 3 for a group, less than 3 to the left to 0 )

0*2 ' 2+0*2 ' 1+1*2 ' 0 1*2 ' 2+0*2 ' 1+0*2 ' 0 1*2 ' 2+0*2 ' 1+0*2 ' 0

1 4 4

Get octal number: 0144

(4) octal turn binary:

such as octal 0324 to binary :

0 3 2 4

divided by 2     0...0      1 ..... 1          1 ..... 0           2 ... 0

divided by 2                  0 ..... 1        0 ..... 1          1 ... 0

0 ... Yu 1

Separate reverse-fetching

00

Less than 3 bits, 0- padded left

The binary is obtained: 011010100(leftmost 0 can be omitted)

(5) binary turn hex

Binary number: 11010100:

1101 0100

1*2 ' 3+1*2 ' 2+0*2 ' 1+1*2 ' 0 0*2 ' 3+1*2 ' 2+0*2 ' 1+0*2 ' 0

8+4+1=13 for D 4

(Number 0--9, starting from the letter a )

That is, Hex: 0xd4

(6) hex turn binary:

Hexadecimal number 0xd4:

(The letter D represents the numbers respectively:)

13 4

Divide by 2 6 ... remainder 1 2 ..... Yu 0

Divide by 2 3 ... remainder 0 1 ..... Yu 0

Divide by 2 1 ... remainder 1 0 ..... Yu 1

Divide by 2 0 ... Yu 1

The remainder is reversed respectively, less than 4 bits to the left with 0 :

1101 0

That gets the binary number: 11010100

Java vs. binary conversion

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.