Java Fundamentals-Binary conversions

Source: Internet
Author: User

Java Fundamentals-Binary conversions

Yun Zhengjie

Copyright Notice: Original works, declined reprint! Otherwise, the legal liability will be investigated.

I. Common binary in Java programs

1> decimal, consisting of 10 numbers "0123456789", every ten into one;

2> binary, consisting of 2 numbers "01", every two in one, beginning with "0b";

3>. Eight binary, composed of "01234567" of the 8 numbers, every eight into one, with the number "0" beginning;

4>. 16 binary, composed of "0123456789abcdef" 16 numbers, every 16 into one, with "0x" start;

Note that in the CPU, memory, the data in the hard disk are "0" and "1", but in the program, we can use any of the above in the system yo.

Two. Conversion of the binary to each other

1>. decimal to Binary binary

For 2, reverse output.

2>. Decimal to Octal

8 Full, Reverse output

3>. Decimal to hexadecimal

For 16, reverse output

4>.

5>.

6>.

Java Fundamentals-Binary conversions

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.