References
2011.09.17 09:46

2진수 <-> 8 진수, 16 진수 변환

조회 수 99505 추천 수 0 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
앞서 10 진수를 기준으로 2,8,16 진수의 변환을 알아 보았습니다. 
  
이번에는 2진수를 8진수와 16진수로 변환하는 방법과 
8진수,16진수를 2진수로 변환하는 방법을 알아 봅니다. 
  
1. 2진수를 16진수로 변환하기. 
2진수로 데이터가 저장되는 정보의 최소 단위인 비트가 4개 모이면 16진수 한 자리에 해당됩니다. 
즉, 아래와 같이 4비트에 메모리에 저장할 수 있는 최대값은 15 가(16진수 f) 됩니다 
  
  1
  1
  1
  1

(1 * 23) + (1 * 22) + (1 * 21) + (1 * 20) = 15(10진수) = F(16진수)

따라서 2진수 4자리는 16진수 한자리에 해당되므로

아래와 같은 2진수를 16진수로 변환 할때는 4자리씩 끊어서 16진수 한자리로 변환하면 됩니다.

11011111 = 1101  1111  =  DF  가 됩니다. 

또한 4자리로 끊었을때 자리수가 부족하면 0으로 채워서 계산하면 됩니다.

1101111 = 0110  1111  =  6F 가 됩니다. 

그리고 소수점을 포함한 2진수도 마찬가지 개념으로 변환하면 됩니다.

1011.011 = 1011  .  0110  = B.6 가 됩니다. 


2. 2진수를 8진수로 변환하기

위의 개념과 완전 동일합니다.

2진수 비트 3개는 8진수 한자에 해당 됩니다.

 

  1
  1
  1

(1 * 22) + (1 * 21) + (1 * 20) = 7(10진수) = 7(8진수)

따라서 2진수 3자리는 8진수 한자리에 해당되므로

아래와 같은 2진수를 8진수로 변환 할때는 3자리씩 끊어서 8진수 한자리로 변환하면 됩니다. 
100101= 100  101  =  45 가 됩니다. 

또한 3자리로 끊었을때 자리수가 부족하면 0으로 채워서 계산하면 됩니다.

10101 = 010  101  =  25 가 됩니다. 

그리고 소수점을 포함한 2진수도 마찬가지 개념으로 변환하면 됩니다. 
100101.1011 = 100  101  .  101  100  = 45.54 가 됩니다. 
  

========================================================================== 
  
2진수를 8진수,16진수를 변환하는 방법에 대해 위에서 살펴 봤습니다. 
그러면 그 역은, 8,16진수를 2진수로 변환하는 방법은 그저 먹기지요?? 
위 개념을 역으로 하면 될테지요.. 
별도의 설명이 필요 없겠으나 하나씩만 해 봅니다. 
  
1.  16진수를 2진수로 변환하기 
위에서 사용한 수를 가지고 해 봅니다. 
위에서 2진수를 16진수로 변환할때 아래와 같았습니다. 
11011111 = 1101  1111  =  DF 
  
16 진수 DF를 2진수로 변환할려면 16진수 한자리는 2진수 4자리에 해당되므로 
D F  =  13  15  = 1101   1111  가 됩니다. 
  
소수점을 가지는 16진수도 완전히 동일하겠지요.. 예는 생략 합니다. 
  
2.  8진수를 2진수로 변환하기 
역시 위에서 사용한 수를 가지고 해 봅니다. 
위에서 2진수를 8진수로 변환할때 아래와 같았습니다. 
100101= 100  101  =  45 
  
8진수 45를 2진수로 변환할려면 8진수 한자리는 2진수 3자리에 해당되므로 
4 5  = 100  101  가 됩니다.


========================================================================== 

#출처 : http://www.mkexdev.net/Article/Content.aspx?parentCategoryID=2&categoryID=9&ID=100

#작성자 : 박종명

?
  • ?
    Hogeony 2011.09.17 09:53
    8진수의 곱셈이나 16진수의 곱셈/나눗셈을 다른 진법으로 고치지 않고 바로 할 수 있다면, 8진수 <-> 16진수 간 변환 가능

    8진수를 16진수로 변경하려면 주어진 8진수를 10진수 16에 해당하는 20(8)로 나누고 몫과 나머지를 나란히 쓰시면 됩니다 (10진수 -> 2진수의 방법과 동일) 그래서 나머지를 차례대로 쓰면 그게 답입니다.

    하지만 만약 그것이 혼동되어 하지 못한다면 10진수나 2진수로 바꿔놓고 하여야 합니다.

    346720(8) / 20(8)을 풀어서 몫과 나머지를 구할 줄 안다면 이 방법으로 변환가능.

  1. Image Upload

    http://imgur.com https://snag.gy/ https://postimages.org/ko/ http://imgur.top/ Clipboard 이미지의 업로드 https://blog.joostory.net/460
    Date2019.07.05 CategoryWeb Design Views44108
    Read More
  2. TensorFlow

    ‘함께하는 딥러닝 컨퍼런스’ 발표 자료입니다. Enjoy! slide: http://bit.ly/keras-in-tf2 script: http://bit.ly/keras-in-tf2-script #Reference https://tensorflow.blog/
    Date2019.07.05 CategoryDeep Learning Views1165
    Read More
  3. Get PyCharm Student Free License (파이참 무료 라이센스 받기)

    Requirement (필요사항) - university domain email adress (학교 도메인으로 된 이메일 주소) such as OOO@OOO.ac.kr / OOO@OOO.edu 1. go to https://www.jetbrains.com/shop/eform/students 2. fill the blank and click the button, "apply for free products" 3. co...
    Date2019.06.19 CategoryPyThon Views99629
    Read More
  4. How to add an external jar file in Android Studio

    To sum it up, when adding an external jar file in Android Studio: Copy jar to root/project/libs folder; Right-click and add as library; Add the jar to root/project/build.gradle (something like compile files('libs/test-jar-to-import.jar')); Mak...
    Date2015.08.06 CategoryCoding Views7421
    Read More
  5. No Image

    extends, interface, implements 의 정의

    A class implements an interface. An interface is an abstract class that only contains method signatures and constant declarations. An interface doesn't contain method definitions and can't be instantiated. A class extends another class. The new class ...
    Date2015.08.05 CategoryEngineering Views14264
    Read More
  6. No Image

    Android 단축키 팁 (생산성 최적화)

    import 정리: ctrl+alt+O 자동 완성/수정 import (show intention actions and quick-fixes): alt+Enter 이름 바꾸기 (Refactoring): shift+F6 자동완성 ctrl+ space 양식 정렬: ctrl+alt+L 메소드 오버라이드 (Override method): ctrl+o 인터페이스 구현 (Implement met...
    Date2015.08.05 CategoryEngineering Views5302
    Read More
  7. No Image

    Better Quality Images from Figures

    If you want better quality images from your figures, I would suggest downloading the submission Myaa by Anders Brun on The MathWorks File Exchange. It allows you to create anti-aliased graphics in MATLAB. Here's a screenshot from the submission illust...
    Date2015.02.03 CategoryEngineering Views5773
    Read More
  8. No Image

    "getframe" not working on 64-bit Windows properly

    Try this, but don't use a docked figure. Just use GETFRAME the normal way, but switch to software rendering of OPENGL. You should still be able to use transparency. opengl('software') #Source: http://www.mathworks.com/matlabcentral/answers/9000-cannot...
    Date2015.02.03 CategoryEngineering Views7489
    Read More
  9. No Image

    msg_make_directory_failed

    # Issuewhen you try to easy install on XE, it doesn't work with popup "msg_make_directory_failed" # Solution1. Go to Admin -> Settings -> FTP Account Information 2. Type the XE Path from the the directory you confront first when you access your FTP a...
    Date2011.09.22 CategoryEngineering Views15624
    Read More
  10. No Image

    2진수 <-> 8 진수, 16 진수 변환

    앞서 10 진수를 기준으로 2,8,16 진수의 변환을 알아 보았습니다. 이번에는 2진수를 8진수와 16진수로 변환하는 방법과 8진수,16진수를 2진수로 변환하는 방법을 알아 봅니다. 1. 2진수를 16진수로 변환하기. 2진수로 데이터가 저장되는 정보의 최소 단위인 비트가 4개 ...
    Date2011.09.17 CategoryReferences Views99505
    Read More
  11. No Image

    Align <Div> at center

    .body { text-align: center; } .body .container {margin: 0 auto; } <div class="body"> <div class="container">{contents}</div> </div> div 가운데 정렬하기 body안에 container를 가운데에 정렬함
    Date2011.08.12 CategoryEngineering Views19452
    Read More
  12. No Image

    [On2 Salsa - Beginner] Outside Turn, Close Cross Body Lead, Inside Turn

    Instructor : 태수&무아 (SkyLatin) Instruction : Holding - Outside Turn - Close Cross Body Lead (C-CBL) - Close Inside Turn
    Date2011.08.11 CategorySalsa Views23074
    Read More
Board Pagination Prev 1 2 3 Next
/ 3