본문 바로가기

JAVA/Study

10. 진수변환 , 진법변환 - arithmetic conversion

영어로 제목을 한것은 나중에 검색할때 유용함을 위해서 했지만

상당히 번거로움을 깨닫게 되고 고통스러움

나를 죽이지못하는 고통은 나를 더 강하게 하니

제목쓸때마다 강해지는중

아무튼 진법(진수) 변환

 

0328-하나도 안유용해서 지금이라도 한글로 바꾸는중 ㅔ케켘

 

    public static void main(String[] args) {
        //10진수를 n진수로 변환
        int i =127; // Decimal
        System.out.println("2진수로 변환 : "+Integer.toBinaryString(i));
        System.out.println("8진수로 변환 : "+Integer.toOctalString(i));
        System.out.println("16진수로 변환 : "+Integer.toHexString(i));
        //n진수를 10진수로
        int a = 0b1111101101; //2진수 binary
        int b = 01755; //8진수 Octal , oct
        int c =0x3ED; // 16진수 Hex
        System.out.println("a를 10진수 : "+a);
        System.out.println("b를 10진수 : " +b);
        System.out.println("c를 10진수 : " +c);
        //10진수는 Decimal 이라 함
    }

}