Java binary Conversion

Source: Internet
Author: User

Example
intN1 = 14;//decimal turns into 16 binary:integer.tohexstring (N1);//decimal into octalinteger.tooctalstring (N1);//decimal turns into binaryInteger.tobinarystring (12);//hex turns into decimalInteger.valueof ("FFFF", 16). toString ();//Hex turns binaryInteger.tobinarystring (integer.valueof ("FFFF", 16));//hex turns into octalInteger.tooctalstring (integer.valueof ("FFFF", 16));//octal turns into decimalInteger.valueof ("576", 8). toString ();//octal turns into binaryInteger.tobinarystring (integer.valueof ("23", 8));//octal turns into hexadecimalInteger.tohexstring (integer.valueof ("23", 8));//Binary goto DecimalInteger.valueof ("0101", 2). toString ();//Binary turn octalInteger.tooctalstring (Integer.parseint ("0101", 2));//Binary turn hexInteger.tohexstring (Integer.parseint ("0101", 2));
Extended

Hex Turn Binary

 Public string hexstring2binarystring (String hexstring) {     int deval = integer.valueof (hexstring,  );      return integer.tobinarystring (deval);}

Java 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.