본문 바로가기

프로그래밍/논리회로

[논리회로] 2진수에서 10진수로 전환하는 방법 (Binary to Decimal Conversion)

[Digital Systems] p.58

 

https://midoriprogramming.tistory.com/2

 

[논리회로] 디지털 수 체계 10진수와 2진수의 이해(Digital Number Systems - Decimal&Binary), 2진수 카운팅

[Digital Systems] p.39-43 ○ Digital Number Systems (디지털 수 체계) 디지털 수 체계를 이해하기 위해서는 2진수(binary), 8진수(octal), 10진수(decimal), 16진수(hexadecimal)에 대한 이해가 필요하다. 2진..

midoriprogramming.tistory.com

 

지난 시간에 디지털 수 체계에 대해서 알아봤다.

 

이번에는 2진수를 10진수로 전환하는 방법에 대해서 알아보겠다

 

○ Binary to Decimal Conversion (2진수에서 10진수 전환)

 

 

● 1을 포함하는 자리수를 더하는 방법 (Sum the positions that contain a 1)

 

1이 존재하는 자리수를 더해주면 된다.

 

예를 들어 10101(2) 라는 숫자가 있다면

 

0번째, 2번째, 4번째가 1이므로

 

각 자리수인 2^0 + 2^2 + 2^4를 더해서 21(10)이라는 숫자를 얻을 수 있다.

 

 

 

 

 

● Double-dabble method

 

 

  1.  2진수의 가장 왼쪽에 있는 1을 쓴다. (Write down the left-most 1 in the binary number.)
  2.  그 수를 2배 한 다음, 오른쪽의 다음 비트를 더해준다. (Double it and add the next bit to the right.)
  3.  덧셈 결과를 다음 비트 아래에 쓴다. (Write down the result under the next bit.)
  4. 2진수 값이 끝날 때까지 2와 3을 반복해준다. (Continue with steps 2 and 3 until finished with the binary number.)

 

 

위 과정을 반복하면 10101(2)를 21(10)로 변환할 수 있다.