Computer/Java
10진수 숫자를 다른진수(16,8,2진수)로 변환해야할 때....
Bitaholic
2007. 8. 29. 18:42
class Integer
static String toBinaryString(int i)
static String toHexString(int i)
static String toOctal(int i)
위의 메소드를 사용하면 손쉽게 변환을 할 수 있다...
== example ==
String hexResult = Integer.toHexString(15);
String binaryResult = Integer.toBinaryString(15);
String octalResult = Integer.toOctal(15);
System.out.println("hexResult = " + hexResult);
System.out.println("binaryResult = " + binaryResult);
System.out.println("octalResult = " + octalResult);
.
.
결과
hexResult = f
binaryResult = 1111
octalResult = 17
static String toBinaryString(int i)
static String toHexString(int i)
static String toOctal(int i)
위의 메소드를 사용하면 손쉽게 변환을 할 수 있다...
== example ==
String hexResult = Integer.toHexString(15);
String binaryResult = Integer.toBinaryString(15);
String octalResult = Integer.toOctal(15);
System.out.println("hexResult = " + hexResult);
System.out.println("binaryResult = " + binaryResult);
System.out.println("octalResult = " + octalResult);
.
.
결과
hexResult = f
binaryResult = 1111
octalResult = 17