Binary, octal, decimal, hexadecimal in Java

Source: Internet
Author: User
Tags binary to decimal decimal to binary

1. Binary

  The binary is a notation that can represent all values with a finite number symbol. is made up of specific values.

2. The representation of the binary  

Binary: consists of 0 and 12 digits.
Octal: Consists of 0-7 numbers, in order to differentiate it from the other binary numbers, beginning with 0.
Decimal: All are made up of 0-9 of these nine digits and cannot start with 0.
Hex: Consists of 0-9 and a-f. To differentiate between other numbers, start with 0x or 0X.

3. Conversion between the binaries

  3.1 Decimal to binary: Divide by 2, reverse the remainder until the quotient is 0. (Integer.tobinarystring (9))

  

3.2 Binary to decimal: each number of binary times is multiplied by 2 N, n indicates the position of the current number starts at 0 and increments by 1 each time. Then each number that comes out is added.

  

3.3 Decimal to 8 binary: divide by 8, reverse the remainder until the quotient is 0.

  

3.4 Octal to decimal: Each number is multiplied by 8 N, n indicates the position of the current number starts at 0 and increments by 1 each time. Then each number that comes out is added.

  

3.5 Decimal to 16 binary: Divide by 16, reverse the remainder until the quotient is 0. Hexadecimal features: 0~9 A (Ten) B (one) c (+) d (+) e (15).

Hexadecimal to decimal: Each number is multiplied by 10 N, n indicates that the current number is in the position starting at 0 and increments by 1 each time. Then each number that comes out is added.

  

  



  

Binary, octal, decimal, hexadecimal in Java

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.