How to convert decimal into binary?
이전 댓글 표시
Hello,
I need to convert n-bit decimal into 2^n bit binary number. I do not have much idea. Can anybody help me please?
댓글 수: 4
Jan
2019년 1월 22일
What exactly is a "n bit decimal"? Integer or floating point values? What about dec2bin?
Sky Scrapper
2019년 1월 22일
편집: Sky Scrapper
2019년 1월 22일
Jan
2019년 1월 22일
2^8 or 2^8-1 ?
채택된 답변
추가 답변 (2개)
PRAVEEN GUPTA
2019년 7월 8일
0 개 추천
i have string of number [240 25 32 32]
i want to convert them in binary
how can i do this???
댓글 수: 2
Jan
2019년 7월 8일
Do no attach a new question as an asnwer of another one.
Did you read this thread? dec2bin has been suggested already, as well as a hand made solution Dec2BinNumeric. Simply use them.
AB WAHEED LONE
2021년 3월 6일
편집: AB WAHEED LONE
2021년 3월 6일
I know it is late but somwhow it may help
bin_array=dec2bin(array,8)-'0';
vandana Ananthagiri
2020년 2월 5일
function A = binary_numbers(n)
A = double(dec2bin(0:((2^n)-1),n))-48;
end
댓글 수: 2
Walter Roberson
2020년 2월 5일
Why 48?
I know the answer, but other people reading your code might not, so I would recommend either a comment or a different representation.
vincent voogt
2021년 11월 1일
Maybe a late reply, but dec2bin return as string of ASCII characters, where 0-9 are mapped on character number 48-57.
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!