LoginSignup
1
1

More than 3 years have passed since last update.

Java 基数の変換方法

Posted at

10進数からn進数へ変換

int x = 11;
int baseNumber = 2;
String result = Integer.toString(x, baseNumber);
System.out.println(result); // 1011

n進数から10進数へ変換

String x = "1e"; // 1e = 16進数
int baseNumber = 10;
int result = Integer.parseInt(x, baseNumber);
System.out.println(result); // 30
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1