How to convert a 5 bit decimal number to 16 bit binary number in Matlab without using dec2bin convertion?

조회 수: 4 (최근 30일)
How to convert a 5 bit decimal number to 16 bit binary number in Matlab without using dec2bin?
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 7월 13일
Are you sure that you want to convert a 5 bit decimal number, and not a 5 digit decimal number?
What is the expected result if the input number is 65536 or larger? What is the expected result if the input number is negative? Does the negative sign count as a digit?

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2015년 7월 13일
Do it the same way you'd do it manually then. divide the number by two repeatedly. The bits are the remainder of the division at each step.
  댓글 수: 1
Guillaume
Guillaume 2015년 7월 13일
As this is most likely homework. No, I cannot give you code.
It's not hard anyway. Use a for loop, divide the number by 2, calculate the remainder and store it into a vector.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by