Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- java 올림
- 백준 16927
- Math.floor()
- 프로그래머스 도둑질 java
- 백준 4375
- 프로그래머스 숫자의 표현 java
- 자바
- java 내림
- 네트워크
- java
- sort
- 백준 18290
- 백준 17425
- java 반올림
- 프로그래머스 네트워크 java
- 백준 11723
- Arrays
- 백준 16935
- Algorithm
- 코딩테스트
- Codility
- mysql
- 0으로 채우기
- 백준 14391
- time complexity
- 프로그래머스 연속된 수의 합 java
- 알고리즘
- 프로그래머스 옹알이 java
- Math.ceil()
- 백준 15661
Archives
- Today
- Total
취미처럼
[JAVA] N진수 변환(2진수, 8진수, 10진수, 16진수) 본문
public static void main(String args[]) {
//10진수
int deciaml = 15;
//2진수
String binaryString = Integer.toBinaryString(deciaml);
int binaryToDecimal = Integer.parseInt(binaryString, 2);
System.out.println(binaryString); //1111
System.out.println(binaryToDecimal); //15
//8진수
String octalString = Integer.toOctalString(deciaml);
int octalToDecimal = Integer.parseInt(octalString, 8);
System.out.println(octalString); //17
System.out.println(octalToDecimal); //15
//16진수
String hexString = Integer.toHexString(deciaml);
int HexToDecimal = Integer.parseInt(hexString, 16);
System.out.println(hexString); //f
System.out.println(HexToDecimal); //15
}
'JAVA > 이론' 카테고리의 다른 글
[JAVA] Scanner(스캐너) 클래스 (0) | 2021.04.15 |
---|---|
[JAVA] BufferedReader vs Scanner (0) | 2021.04.13 |
[JAVA] 문자열 형 변환 비교(casting VS toString VS String.valueOf) (0) | 2021.03.23 |
[JAVA] 콜백 (0) | 2021.03.23 |
[JAVA] 참조 (0) | 2021.03.23 |
Comments