Conversion between the binaries

Source: Internet
Author: User
Tags decimal to binary

conversion between the binaries

Conversion between binaries in Java, decimal to binary, octal, hex. Other binary decimal.

What about the conversions between these binaries?

Read the question:

The Write function outputs a decimal number to its corresponding octal number.

Sample input

9274

Sample output

22072

Code:

import java.util.*;

Public class Shizhuanba {

Public Static void Main (string[] args)

{

Scanner in =new Scanner (System. in);

int a=in.nextint ();

Integer.tooctalstring (a);

System. out. println (Integer. Tooctalstring(a);

}

}

Summary: Binary, octal, decimal, 16 binary conversion

A: Decimal Conversion Other

Decimal conversion Binary

Integer.tobinarystring (i);

Decimal conversion octal

Integer.tooctalstring (i);

Decimal conversion hexadecimal

Integer.tohexstring (i);

B: Other binary conversion decimal

Binary Conversion Decimal

Integer.valueof ("1010", 2). ToString ();

Octal Conversion Decimal

Integer.valueof ("8"). ToString ();

16 Binary Conversion Decimal

Integer.valueof ("ABCDEF", +). toString ();

This is in Java programming commonly used in the conversion, I hope to help you!

Conversion between the binaries

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.