Get the App
SLTechnology News&Howtos  ›  Development  › 

An example Analysis of JAVA binary conversion

Shulou Source: shulou.com Published: 2022-06-01 17:25:25 10月05日 Update

Most people do not understand the knowledge points of this "JAVA base conversion example analysis" article, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "JAVA base conversion case analysis" article.

The binary conversion has been encapsulated in the Integer object in JAVA. Whether it is the conventional method of converting 10-turn 2pr 8 to 16, or the corresponding method of converting hexadecimal to decimal, of course, it also includes the conventional methods from 10-> n to decimal.

Convert decimal to hexadecimal:

Integer.toHexString (int I)

Convert decimal to octal

Integer.toOctalString (int I)

Convert decimal to binary

Integer.toBinaryString (int I)

Convert hexadecimal to decimal

Integer.valueOf (FFFF, 16). ToString ()

Convert octal to decimal

Integer.valueOf (876, 8). ToString ()

Binary to decimal

Integer.valueOf (0101, 2). ToString ()

Demo:

Package com.ask.test;public class Test16to2 {public static void main (String [] args) {String a = Integer.valueOf ("E4E2C4", 16). ToString (); System.out.println ("hexadecimal data" E4E2C4 "corresponding to decimal data is:" + a); String b = Integer.toBinaryString (Integer.parseInt (a)); System.out.println (binary data corresponding to "hexadecimal data" E4E2C4 "is:" + b) }} the above is about the content of the article "JAVA binary conversion example Analysis". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Binary content decimal decimal data example case analysis analysis binary octal hexadecimal general article method knowledge article value most object is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno Apple MySQL macOS